about summary refs log tree commit diff
path: root/app/services/after_block_domain_from_account_service.rb
diff options
context:
space:
mode:
authorEugen Rochko <eugen@zeonfederated.com>2019-07-25 04:17:35 +0200
committerGitHub <noreply@github.com>2019-07-25 04:17:35 +0200
commit4eeff26533b75b592395e353c6d4506db9958bcf (patch)
treecfb3483e2c6d24ed0d6ae0e390cba0e274285700 /app/services/after_block_domain_from_account_service.rb
parent94f5c714f11248df6a2b793f47cdb30028f67fca (diff)
Change account domain block to clear out notifications and follows (#11393)
Diffstat (limited to 'app/services/after_block_domain_from_account_service.rb')
-rw-r--r--app/services/after_block_domain_from_account_service.rb12
1 files changed, 12 insertions, 0 deletions
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)