after_block_service.rb 788 B

12345678910111213141516171819202122232425262728293031
  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_list_feeds!
  8. clear_notifications!
  9. clear_conversations!
  10. end
  11. private
  12. def clear_home_feed!
  13. FeedManager.instance.clear_from_home(@account, @target_account)
  14. end
  15. def clear_list_feeds!
  16. FeedManager.instance.clear_from_lists(@account, @target_account)
  17. end
  18. def clear_conversations!
  19. AccountConversation.where(account: @account).where('? = ANY(participant_account_ids)', @target_account.id).in_batches.destroy_all
  20. end
  21. def clear_notifications!
  22. Notification.where(account: @account).where(from_account: @target_account).in_batches.delete_all
  23. end
  24. end