mirror of
https://github.com/mastodon/mastodon.git
synced 2024-08-20 21:08:15 -07:00
Make use of existing Account.with_domain
scope for ReportService#reported_status_ids
This commit is contained in:
parent
584b1524dd
commit
e1008e9eb5
1 changed files with 10 additions and 1 deletions
|
@ -86,7 +86,7 @@ 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(exists_mention_for_domain_accounts(domain))))
|
||||
# Allow missing posts to not drop reports that include e.g. a deleted post
|
||||
scope.where(id: Array(@status_ids)).pluck(:id)
|
||||
end
|
||||
|
@ -98,4 +98,13 @@ class ReportService < BaseService
|
|||
def some_local_account
|
||||
@some_local_account ||= Account.representative
|
||||
end
|
||||
|
||||
def exists_mention_for_domain_accounts(domain)
|
||||
Mention
|
||||
.joins(:account)
|
||||
.merge(Account.with_domain(domain))
|
||||
.select(1)
|
||||
.arel
|
||||
.exists
|
||||
end
|
||||
end
|
||||
|
|
Loading…
Reference in a new issue