Add forward_to_domains
parameter to POST /api/v1/reports
(#25866)
This commit is contained in:
parent
f3fca78756
commit
c27b82a437
6 changed files with 153 additions and 80 deletions
|
@ -16,7 +16,11 @@ class ReportService < BaseService
|
|||
|
||||
create_report!
|
||||
notify_staff!
|
||||
forward_to_origin! if forward?
|
||||
|
||||
if forward?
|
||||
forward_to_origin!
|
||||
forward_to_replied_to!
|
||||
end
|
||||
|
||||
@report
|
||||
end
|
||||
|
@ -29,7 +33,7 @@ class ReportService < BaseService
|
|||
status_ids: reported_status_ids,
|
||||
comment: @comment,
|
||||
uri: @options[:uri],
|
||||
forwarded: forward?,
|
||||
forwarded: forward_to_origin?,
|
||||
category: @category,
|
||||
rule_ids: @rule_ids
|
||||
)
|
||||
|
@ -45,11 +49,15 @@ class ReportService < BaseService
|
|||
end
|
||||
|
||||
def forward_to_origin!
|
||||
return unless forward_to_origin?
|
||||
|
||||
# Send report to the server where the account originates from
|
||||
ActivityPub::DeliveryWorker.perform_async(payload, some_local_account.id, @target_account.inbox_url)
|
||||
end
|
||||
|
||||
def forward_to_replied_to!
|
||||
# Send report to servers to which the account was replying to, so they also have a chance to act
|
||||
inbox_urls = Account.remote.where(id: Status.where(id: reported_status_ids).where.not(in_reply_to_account_id: nil).select(:in_reply_to_account_id)).inboxes - [@target_account.inbox_url]
|
||||
inbox_urls = Account.remote.where(domain: forward_to_domains).where(id: Status.where(id: reported_status_ids).where.not(in_reply_to_account_id: nil).select(:in_reply_to_account_id)).inboxes - [@target_account.inbox_url]
|
||||
|
||||
inbox_urls.each do |inbox_url|
|
||||
ActivityPub::DeliveryWorker.perform_async(payload, some_local_account.id, inbox_url)
|
||||
|
@ -60,6 +68,14 @@ class ReportService < BaseService
|
|||
!@target_account.local? && ActiveModel::Type::Boolean.new.cast(@options[:forward])
|
||||
end
|
||||
|
||||
def forward_to_origin?
|
||||
forward? && forward_to_domains.include?(@target_account.domain)
|
||||
end
|
||||
|
||||
def forward_to_domains
|
||||
@forward_to_domains ||= (@options[:forward_to_domains] || [@target_account.domain]).filter_map { |domain| TagManager.instance.normalize_domain(domain&.strip) }.uniq
|
||||
end
|
||||
|
||||
def reported_status_ids
|
||||
return AccountStatusesFilter.new(@target_account, @source_account).results.with_discarded.find(Array(@status_ids)).pluck(:id) if @source_account.local?
|
||||
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue