From 2374a00c1062a70e9092d88579e1351e4c8128f9 Mon Sep 17 00:00:00 2001 From: Eugen Rochko Date: Wed, 22 Aug 2018 11:53:41 +0200 Subject: Add confirmation step to account suspensions (#8353) * Add confirmation page for suspensions * Suspension confirmation closes reports, linked from report UI * Fix tests --- app/models/account.rb | 7 +++++++ app/models/form/admin_suspension_confirmation.rb | 7 +++++++ 2 files changed, 14 insertions(+) create mode 100644 app/models/form/admin_suspension_confirmation.rb (limited to 'app/models') diff --git a/app/models/account.rb b/app/models/account.rb index c33ec4bd5..440a731e3 100644 --- a/app/models/account.rb +++ b/app/models/account.rb @@ -193,6 +193,13 @@ class Account < ApplicationRecord ResolveAccountService.new.call(acct) end + def suspend! + transaction do + user&.disable! if local? + update!(suspended: true) + end + end + def unsuspend! transaction do user&.enable! if local? diff --git a/app/models/form/admin_suspension_confirmation.rb b/app/models/form/admin_suspension_confirmation.rb new file mode 100644 index 000000000..c34b5b30e --- /dev/null +++ b/app/models/form/admin_suspension_confirmation.rb @@ -0,0 +1,7 @@ +# frozen_string_literal: true + +class Form::AdminSuspensionConfirmation + include ActiveModel::Model + + attr_accessor :acct, :report_id +end -- cgit From 4bdab203ac5ca06d757d08af8a2bc184c86e3bbe Mon Sep 17 00:00:00 2001 From: masarakki Date: Wed, 22 Aug 2018 20:20:50 +0900 Subject: exclude-other-silenced-accounts (#7528) --- app/models/status.rb | 3 ++- spec/models/status_spec.rb | 11 ----------- 2 files changed, 2 insertions(+), 12 deletions(-) (limited to 'app/models') diff --git a/app/models/status.rb b/app/models/status.rb index 6ba7b7a50..35655bff2 100644 --- a/app/models/status.rb +++ b/app/models/status.rb @@ -384,7 +384,8 @@ class Status < ApplicationRecord def account_silencing_filter(account) if account.silenced? - including_silenced_accounts + including_myself = left_outer_joins(:account).where(account_id: account.id).references(:accounts) + excluding_silenced_accounts.or(including_myself) else excluding_silenced_accounts end diff --git a/spec/models/status_spec.rb b/spec/models/status_spec.rb index d03005107..9d8670129 100644 --- a/spec/models/status_spec.rb +++ b/spec/models/status_spec.rb @@ -573,17 +573,6 @@ RSpec.describe Status, type: :model do expect(results).to include(es_status) end end - - context 'where that account is silenced' do - it 'includes statuses from other accounts that are silenced' do - @account.update(silenced: true) - other_silenced_account = Fabricate(:account, silenced: true) - other_status = Fabricate(:status, account: other_silenced_account) - - results = Status.as_public_timeline(@account) - expect(results).to include(other_status) - end - end end end -- cgit