Refactor StatusReachFinder to be used in more places

This commit is contained in:
Eugen Rochko 2021-09-25 00:17:36 +02:00
parent c99d28369a
commit ce463ccb50
13 changed files with 321 additions and 99 deletions

View file

@ -1,12 +1,13 @@
# frozen_string_literal: true
class AccountReachFinder
def initialize(account)
def initialize(account, options = {})
@account = account
@options = options
end
def inboxes
(followers_inboxes + reporters_inboxes + relay_inboxes).uniq
(followers_inboxes + reporters_inboxes + blocked_by_inboxes + relay_inboxes).uniq
end
private
@ -19,6 +20,14 @@ class AccountReachFinder
Account.where(id: @account.targeted_reports.select(:account_id)).inboxes
end
def blocked_by_inboxes
if @options[:with_blocking_accounts]
@account.blocked_by.inboxes
else
[]
end
end
def relay_inboxes
Relay.enabled.pluck(:inbox_url)
end