mirror of
https://github.com/mastodon/mastodon.git
synced 2025-09-08 10:50:58 +00:00
Change StatusReachFinder
to consider quotes as well as reblogs (#35601)
This commit is contained in:
parent
e8e6cf9510
commit
31ba52a57b
|
@ -30,8 +30,10 @@ class StatusReachFinder
|
||||||
[
|
[
|
||||||
replied_to_account_id,
|
replied_to_account_id,
|
||||||
reblog_of_account_id,
|
reblog_of_account_id,
|
||||||
|
quote_of_account_id,
|
||||||
mentioned_account_ids,
|
mentioned_account_ids,
|
||||||
reblogs_account_ids,
|
reblogs_account_ids,
|
||||||
|
quotes_account_ids,
|
||||||
favourites_account_ids,
|
favourites_account_ids,
|
||||||
replies_account_ids,
|
replies_account_ids,
|
||||||
].tap do |arr|
|
].tap do |arr|
|
||||||
|
@ -46,6 +48,10 @@ class StatusReachFinder
|
||||||
@status.in_reply_to_account_id if distributable?
|
@status.in_reply_to_account_id if distributable?
|
||||||
end
|
end
|
||||||
|
|
||||||
|
def quote_of_account_id
|
||||||
|
@status.quote&.quoted_account_id
|
||||||
|
end
|
||||||
|
|
||||||
def reblog_of_account_id
|
def reblog_of_account_id
|
||||||
@status.reblog.account_id if @status.reblog?
|
@status.reblog.account_id if @status.reblog?
|
||||||
end
|
end
|
||||||
|
@ -54,6 +60,11 @@ class StatusReachFinder
|
||||||
@status.mentions.pluck(:account_id)
|
@status.mentions.pluck(:account_id)
|
||||||
end
|
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
|
# Beware: Reblogs can be created without the author having had access to the status
|
||||||
def reblogs_account_ids
|
def reblogs_account_ids
|
||||||
@status.reblogs.rewhere(deleted_at: [nil, @status.deleted_at]).pluck(:account_id) if distributable? || unsafe?
|
@status.reblogs.rewhere(deleted_at: [nil, @status.deleted_at]).pluck(:account_id) if distributable? || unsafe?
|
||||||
|
|
|
@ -78,6 +78,7 @@ class Status < ApplicationRecord
|
||||||
has_many :mentions, dependent: :destroy, inverse_of: :status
|
has_many :mentions, dependent: :destroy, inverse_of: :status
|
||||||
has_many :mentioned_accounts, through: :mentions, source: :account, class_name: 'Account'
|
has_many :mentioned_accounts, through: :mentions, source: :account, class_name: 'Account'
|
||||||
has_many :media_attachments, dependent: :nullify
|
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
|
# 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
|
has_many :active_mentions, -> { active }, class_name: 'Mention', inverse_of: :status # rubocop:disable Rails/HasManyOrHasOneDependent
|
||||||
|
|
Loading…
Reference in New Issue
Block a user