mirror of
https://github.com/mastodon/mastodon.git
synced 2025-09-05 17:31:12 +00:00
Merge ae37b32b11
into 14cb5ff881
This commit is contained in:
commit
0ce654acc5
|
@ -48,12 +48,20 @@ class AccountStatusesFilter
|
||||||
def filtered_scope
|
def filtered_scope
|
||||||
scope = account.statuses.left_outer_joins(:mentions)
|
scope = account.statuses.left_outer_joins(:mentions)
|
||||||
|
|
||||||
scope.merge!(scope.where(visibility: follower? ? %i(public unlisted private) : %i(public unlisted)).or(scope.where(mentions: { account_id: current_account.id })).group(Status.arel_table[:id]))
|
scope.merge!(visibility_scope(scope).or(scope.where(mentions: { account_id: current_account.id })).group(Status.arel_table[:id]))
|
||||||
scope.merge!(filtered_reblogs_scope) if reblogs_may_occur?
|
scope.merge!(filtered_reblogs_scope) if reblogs_may_occur?
|
||||||
|
|
||||||
scope
|
scope
|
||||||
end
|
end
|
||||||
|
|
||||||
|
def visibility_scope(scope)
|
||||||
|
if follower?
|
||||||
|
scope.list_eligible_visibility
|
||||||
|
else
|
||||||
|
scope.distributable_visibility
|
||||||
|
end
|
||||||
|
end
|
||||||
|
|
||||||
def filtered_reblogs_scope
|
def filtered_reblogs_scope
|
||||||
scope = Status.left_outer_joins(reblog: :account)
|
scope = Status.left_outer_joins(reblog: :account)
|
||||||
scope
|
scope
|
||||||
|
|
|
@ -155,7 +155,7 @@ class REST::StatusSerializer < ActiveModel::Serializer
|
||||||
current_user? &&
|
current_user? &&
|
||||||
current_user.account_id == object.account_id &&
|
current_user.account_id == object.account_id &&
|
||||||
!object.reblog? &&
|
!object.reblog? &&
|
||||||
%w(public unlisted private).include?(object.visibility)
|
StatusRelationshipsPresenter::PINNABLE_VISIBILITIES.include?(object.visibility)
|
||||||
end
|
end
|
||||||
|
|
||||||
def source_requested?
|
def source_requested?
|
||||||
|
|
|
@ -82,15 +82,24 @@ class ReportService < BaseService
|
||||||
return AccountStatusesFilter.new(@target_account, @source_account).results.with_discarded.find(Array(@status_ids)).pluck(:id) if @source_account.local?
|
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.
|
# 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 = @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!(visibility_scope(scope).or(scope.where('EXISTS (SELECT 1 FROM mentions m JOIN accounts a ON m.account_id = a.id WHERE lower(a.domain) = ?)', @source_account.domain.to_s.downcase)))
|
||||||
# Allow missing posts to not drop reports that include e.g. a deleted post
|
# Allow missing posts to not drop reports that include e.g. a deleted post
|
||||||
scope.where(id: Array(@status_ids)).pluck(:id)
|
scope.where(id: Array(@status_ids)).pluck(:id)
|
||||||
end
|
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
|
def payload
|
||||||
Oj.dump(serialize_payload(@report, ActivityPub::FlagSerializer, account: some_local_account))
|
Oj.dump(serialize_payload(@report, ActivityPub::FlagSerializer, account: some_local_account))
|
||||||
end
|
end
|
||||||
|
|
Loading…
Reference in New Issue
Block a user