after_block_service.rb 666 B

1234567891011121314151617181920212223242526
  1. # frozen_string_literal: true
  2. class AfterBlockService < BaseService
  3. def call(account, target_account)
  4. @account = account
  5. @target_account = target_account
  6. clear_home_feed!
  7. clear_notifications!
  8. clear_conversations!
  9. end
  10. private
  11. def clear_home_feed!
  12. FeedManager.instance.clear_from_home(@account, @target_account)
  13. end
  14. def clear_conversations!
  15. AccountConversation.where(account: @account).where('? = ANY(participant_account_ids)', @target_account.id).in_batches.destroy_all
  16. end
  17. def clear_notifications!
  18. Notification.where(account: @account).where(from_account: @target_account).in_batches.delete_all
  19. end
  20. end