0
0
Fork 0

Change account domain block to clear out notifications and follows (#11393)

This commit is contained in:
Eugen Rochko 2019-07-25 04:17:35 +02:00 committed by GitHub
parent 94f5c714f1
commit 4eeff26533
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
7 changed files with 51 additions and 35 deletions

View file

@ -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)