after_block_service.rb 955 B

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