This repository has been archived on 2024-06-09. You can view files and clone it, but cannot push or open issues/pull-requests.
2021-04-17 14:55:46 +02:00
|
|
|
# frozen_string_literal: true
|
|
|
|
|
|
|
|
class AccountReachFinder
|
|
|
|
def initialize(account)
|
|
|
|
@account = account
|
|
|
|
end
|
|
|
|
|
|
|
|
def inboxes
|
2023-05-12 13:13:04 +02:00
|
|
|
(followers_inboxes + reporters_inboxes + recently_mentioned_inboxes + relay_inboxes).uniq
|
2021-04-17 14:55:46 +02:00
|
|
|
end
|
|
|
|
|
|
|
|
private
|
|
|
|
|
|
|
|
def followers_inboxes
|
|
|
|
@account.followers.inboxes
|
|
|
|
end
|
|
|
|
|
|
|
|
def reporters_inboxes
|
|
|
|
Account.where(id: @account.targeted_reports.select(:account_id)).inboxes
|
|
|
|
end
|
|
|
|
|
2023-05-12 13:13:04 +02:00
|
|
|
def recently_mentioned_inboxes
|
|
|
|
cutoff_id = Mastodon::Snowflake.id_at(2.days.ago, with_random: false)
|
|
|
|
recent_statuses = @account.statuses.recent.where(id: cutoff_id...).limit(200)
|
|
|
|
|
|
|
|
Account.joins(:mentions).where(mentions: { status: recent_statuses }).inboxes.take(2000)
|
|
|
|
end
|
|
|
|
|
2021-04-17 14:55:46 +02:00
|
|
|
def relay_inboxes
|
|
|
|
Relay.enabled.pluck(:inbox_url)
|
|
|
|
end
|
|
|
|
end
|