From 4eeff26533b75b592395e353c6d4506db9958bcf Mon Sep 17 00:00:00 2001 From: Eugen Rochko Date: Thu, 25 Jul 2019 04:17:35 +0200 Subject: Change account domain block to clear out notifications and follows (#11393) --- app/services/after_block_domain_from_account_service.rb | 12 ++++++++++++ 1 file changed, 12 insertions(+) (limited to 'app/services/after_block_domain_from_account_service.rb') diff --git a/app/services/after_block_domain_from_account_service.rb b/app/services/after_block_domain_from_account_service.rb index a87c2e792..f50bde261 100644 --- a/app/services/after_block_domain_from_account_service.rb +++ b/app/services/after_block_domain_from_account_service.rb @@ -10,12 +10,24 @@ class AfterBlockDomainFromAccountService < BaseService @account = account @domain = domain + clear_notifications! + remove_follows! reject_existing_followers! reject_pending_follow_requests! end private + def remove_follows! + @account.active_relationships.where(account: Account.where(domain: @domain)).includes(:target_account).reorder(nil).find_each do |follow| + UnfollowService.new.call(@account, follow.target_account) + end + end + + def clear_notifications! + Notification.where(account: @account).where(from_account: Account.where(domain: @domain)).in_batches.delete_all + end + def reject_existing_followers! @account.passive_relationships.where(account: Account.where(domain: @domain)).includes(:account).reorder(nil).find_each do |follow| reject_follow!(follow) -- cgit