mirror of
https://github.com/mastodon/mastodon.git
synced 2026-03-21 18:05:23 -05:00
Merge 51a175cfbf into 4e276e4476
This commit is contained in:
commit
db5df69efc
|
|
@ -84,19 +84,16 @@ 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?
|
||||
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!(visibility_scope(scope).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)
|
||||
.where(Account.arel_table[:domain].lower.eq domain)
|
||||
.merge(Account.with_domain(@source_account.domain))
|
||||
.select(1).arel.exists
|
||||
end
|
||||
|
||||
|
|
@ -104,6 +101,18 @@ class ReportService < BaseService
|
|||
@target_account.collections.find(Array(@collection_ids)).pluck(:id)
|
||||
end
|
||||
|
||||
def visibility_scope(scope)
|
||||
if target_has_source_domain_followers?
|
||||
scope.list_eligible_visibility
|
||||
else
|
||||
scope.distributable_visibility
|
||||
end
|
||||
end
|
||||
|
||||
def target_has_source_domain_followers?
|
||||
@target_account.followers.with_domain(@source_account.domain).exists?
|
||||
end
|
||||
|
||||
def payload
|
||||
serialize_payload(@report, ActivityPub::FlagSerializer, account: some_local_account).to_json
|
||||
end
|
||||
|
|
|
|||
Loading…
Reference in New Issue
Block a user