Change StatusReachFinder to consider quotes as well as reblogs (#35601)

This commit is contained in:
Claire 2025-07-30 16:07:01 +02:00 committed by GitHub
parent e8e6cf9510
commit 31ba52a57b
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194
2 changed files with 12 additions and 0 deletions

View File

@ -30,8 +30,10 @@ class StatusReachFinder
[
replied_to_account_id,
reblog_of_account_id,
quote_of_account_id,
mentioned_account_ids,
reblogs_account_ids,
quotes_account_ids,
favourites_account_ids,
replies_account_ids,
].tap do |arr|
@ -46,6 +48,10 @@ class StatusReachFinder
@status.in_reply_to_account_id if distributable?
end
def quote_of_account_id
@status.quote&.quoted_account_id
end
def reblog_of_account_id
@status.reblog.account_id if @status.reblog?
end
@ -54,6 +60,11 @@ class StatusReachFinder
@status.mentions.pluck(:account_id)
end
# Beware: Quotes can be created without the author having had access to the status
def quotes_account_ids
@status.quotes.pluck(:account_id) if distributable? || unsafe?
end
# Beware: Reblogs can be created without the author having had access to the status
def reblogs_account_ids
@status.reblogs.rewhere(deleted_at: [nil, @status.deleted_at]).pluck(:account_id) if distributable? || unsafe?

View File

@ -78,6 +78,7 @@ class Status < ApplicationRecord
has_many :mentions, dependent: :destroy, inverse_of: :status
has_many :mentioned_accounts, through: :mentions, source: :account, class_name: 'Account'
has_many :media_attachments, dependent: :nullify
has_many :quotes, foreign_key: 'quoted_status_id', inverse_of: :quoted_status, dependent: :nullify
# The `dependent` option is enabled by the initial `mentions` association declaration
has_many :active_mentions, -> { active }, class_name: 'Mention', inverse_of: :status # rubocop:disable Rails/HasManyOrHasOneDependent