1
0

account_reach_finder.rb 770 B

1234567891011121314151617181920212223242526272829303132
  1. # frozen_string_literal: true
  2. class AccountReachFinder
  3. def initialize(account)
  4. @account = account
  5. end
  6. def inboxes
  7. (followers_inboxes + reporters_inboxes + recently_mentioned_inboxes + relay_inboxes).uniq
  8. end
  9. private
  10. def followers_inboxes
  11. @account.followers.inboxes
  12. end
  13. def reporters_inboxes
  14. Account.where(id: @account.targeted_reports.select(:account_id)).inboxes
  15. end
  16. def recently_mentioned_inboxes
  17. cutoff_id = Mastodon::Snowflake.id_at(2.days.ago, with_random: false)
  18. recent_statuses = @account.statuses.recent.where(id: cutoff_id...).limit(200)
  19. Account.joins(:mentions).where(mentions: { status: recent_statuses }).inboxes.take(2000)
  20. end
  21. def relay_inboxes
  22. Relay.enabled.pluck(:inbox_url)
  23. end
  24. end