You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

31 lines
788 B

  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