The code powering m.abunchtell.com https://m.abunchtell.com
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.
 
 
 
 

45 lines
1.5 KiB

  1. # frozen_string_literal: true
  2. class AfterBlockService < BaseService
  3. def call(account, target_account)
  4. clear_home_feed(account, target_account)
  5. clear_notifications(account, target_account)
  6. clear_conversations(account, target_account)
  7. end
  8. private
  9. def clear_home_feed(account, target_account)
  10. FeedManager.instance.clear_from_timeline(account, target_account)
  11. end
  12. def clear_conversations(account, target_account)
  13. AccountConversation.where(account: account)
  14. .where('? = ANY(participant_account_ids)', target_account.id)
  15. .in_batches
  16. .destroy_all
  17. end
  18. def clear_notifications(account, target_account)
  19. Notification.where(account: account)
  20. .joins(:follow)
  21. .where(activity_type: 'Follow', follows: { account_id: target_account.id })
  22. .delete_all
  23. Notification.where(account: account)
  24. .joins(mention: :status)
  25. .where(activity_type: 'Mention', statuses: { account_id: target_account.id })
  26. .delete_all
  27. Notification.where(account: account)
  28. .joins(:favourite)
  29. .where(activity_type: 'Favourite', favourites: { account_id: target_account.id })
  30. .delete_all
  31. Notification.where(account: account)
  32. .joins(:status)
  33. .where(activity_type: 'Status', statuses: { account_id: target_account.id })
  34. .delete_all
  35. end
  36. end