about summary refs log tree commit diff
path: root/app/services/after_block_domain_from_account_service.rb
diff options
context:
space:
mode:
authorThibG <thib@sitedethib.com>2019-07-29 23:37:14 +0200
committerGitHub <noreply@github.com>2019-07-29 23:37:14 +0200
commitf48c7689d230b915ed740a4774736bd5998cbc66 (patch)
tree3d883f06fe8e3abbc5653e029ac8612ae114f135 /app/services/after_block_domain_from_account_service.rb
parenta4a81c5434c73139f7c1d66f2687039237c5208a (diff)
parent51411267fda00db576230a270a10e31992378c18 (diff)
Merge pull request #1179 from ThibG/glitch-soc/merge-upstream
Merge upstream changes
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)