diff --git a/app/lib/status_reach_finder.rb b/app/lib/status_reach_finder.rb index 5fb19643378..3ff04c4b69b 100644 --- a/app/lib/status_reach_finder.rb +++ b/app/lib/status_reach_finder.rb @@ -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? diff --git a/app/models/status.rb b/app/models/status.rb index 51150bec49e..c99a1f8df56 100644 --- a/app/models/status.rb +++ b/app/models/status.rb @@ -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