2020-11-27 14:48:31 +00:00
|
|
|
# frozen_string_literal: true
|
|
|
|
|
|
|
|
class StatusReachFinder
|
|
|
|
def initialize(status)
|
|
|
|
@status = status
|
|
|
|
end
|
|
|
|
|
|
|
|
def inboxes
|
2021-04-17 13:41:57 +00:00
|
|
|
(reached_account_inboxes + followers_inboxes + relay_inboxes).uniq
|
2020-11-27 14:48:31 +00:00
|
|
|
end
|
|
|
|
|
|
|
|
private
|
|
|
|
|
2021-04-17 13:41:57 +00:00
|
|
|
def reached_account_inboxes
|
|
|
|
# When the status is a reblog, there are no interactions with it
|
|
|
|
# directly, we assume all interactions are with the original one
|
|
|
|
|
|
|
|
if @status.reblog?
|
|
|
|
[]
|
|
|
|
else
|
|
|
|
Account.where(id: reached_account_ids).inboxes
|
|
|
|
end
|
|
|
|
end
|
|
|
|
|
2020-11-27 14:48:31 +00:00
|
|
|
def reached_account_ids
|
|
|
|
[
|
|
|
|
replied_to_account_id,
|
|
|
|
reblog_of_account_id,
|
|
|
|
mentioned_account_ids,
|
|
|
|
reblogs_account_ids,
|
|
|
|
favourites_account_ids,
|
|
|
|
replies_account_ids,
|
|
|
|
].tap do |arr|
|
|
|
|
arr.flatten!
|
|
|
|
arr.compact!
|
|
|
|
arr.uniq!
|
|
|
|
end
|
|
|
|
end
|
|
|
|
|
|
|
|
def replied_to_account_id
|
|
|
|
@status.in_reply_to_account_id
|
|
|
|
end
|
|
|
|
|
|
|
|
def reblog_of_account_id
|
|
|
|
@status.reblog.account_id if @status.reblog?
|
|
|
|
end
|
|
|
|
|
|
|
|
def mentioned_account_ids
|
|
|
|
@status.mentions.pluck(:account_id)
|
|
|
|
end
|
|
|
|
|
|
|
|
def reblogs_account_ids
|
|
|
|
@status.reblogs.pluck(:account_id)
|
|
|
|
end
|
|
|
|
|
|
|
|
def favourites_account_ids
|
|
|
|
@status.favourites.pluck(:account_id)
|
|
|
|
end
|
|
|
|
|
|
|
|
def replies_account_ids
|
|
|
|
@status.replies.pluck(:account_id)
|
|
|
|
end
|
2021-04-17 13:41:57 +00:00
|
|
|
|
|
|
|
def followers_inboxes
|
2021-04-24 11:35:39 +00:00
|
|
|
if @status.in_reply_to_local_account? && @status.distributable?
|
2020-03-05 13:26:30 +00:00
|
|
|
@status.account.delivery_followers.or(@status.thread.account.delivery_followers).inboxes
|
2021-04-22 12:26:11 +00:00
|
|
|
else
|
2020-03-05 13:26:30 +00:00
|
|
|
@status.account.delivery_followers.inboxes
|
2021-04-22 12:26:11 +00:00
|
|
|
end
|
2021-04-17 13:41:57 +00:00
|
|
|
end
|
|
|
|
|
|
|
|
def relay_inboxes
|
|
|
|
if @status.public_visibility?
|
|
|
|
Relay.enabled.pluck(:inbox_url)
|
|
|
|
else
|
|
|
|
[]
|
|
|
|
end
|
|
|
|
end
|
2020-11-27 14:48:31 +00:00
|
|
|
end
|