Rely on normalization from scope in report service (#39755)

This commit is contained in:
Matt Jankowski 2026-07-13 02:10:27 -04:00 committed by GitHub
parent 4f1e66dc7d
commit e558c484ee
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194

View File

@ -84,19 +84,18 @@ class ReportService < BaseService
return AccountStatusesFilter.new(@target_account, @source_account).results.with_discarded.find(Array(@status_ids)).pluck(:id) if @source_account.local?
# If the account making reports is remote, it is likely anonymized so we have to relax the requirements for attaching statuses.
domain = @source_account.domain.to_s.downcase
has_followers = @target_account.followers.with_domain(domain).exists?
has_followers = @target_account.followers.with_domain(@source_account.domain).exists?
visibility = has_followers ? %i(public unlisted private) : %i(public unlisted)
scope = @target_account.statuses.with_discarded
scope.merge!(scope.where(visibility: visibility).or(scope.where(domain_mentions(domain))))
scope.merge!(scope.where(visibility: visibility).or(scope.where(domain_mentions)))
# Allow missing posts to not drop reports that include e.g. a deleted post
scope.where(id: Array(@status_ids)).pluck(:id)
end
def domain_mentions(domain)
def domain_mentions
Mention
.joins(:account)
.merge(Account.with_domain(domain))
.merge(Account.with_domain(@source_account.domain))
.select(1).arel.exists
end