mirror of
https://github.com/glitch-soc/mastodon.git
synced 2026-03-29 03:00:33 +02:00
Use Mention arel/exist in report service scope build-out (#38300)
This commit is contained in:
@@ -88,11 +88,18 @@ class ReportService < BaseService
|
||||
has_followers = @target_account.followers.with_domain(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('EXISTS (SELECT 1 FROM mentions m JOIN accounts a ON m.account_id = a.id WHERE lower(a.domain) = ?)', domain)))
|
||||
scope.merge!(scope.where(visibility: visibility).or(scope.where(domain_mentions(domain))))
|
||||
# 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)
|
||||
Mention
|
||||
.joins(:account)
|
||||
.where(Account.arel_table[:domain].lower.eq domain)
|
||||
.select(1).arel.exists
|
||||
end
|
||||
|
||||
def reported_collection_ids
|
||||
@target_account.collections.find(Array(@collection_ids)).pluck(:id)
|
||||
end
|
||||
|
||||
Reference in New Issue
Block a user