mirror of
https://github.com/mastodon/mastodon.git
synced 2025-01-09 10:04:38 +01:00
31 lines
609 B
Ruby
31 lines
609 B
Ruby
|
# frozen_string_literal: true
|
||
|
|
||
|
class ForwardReportService < BaseService
|
||
|
include Payloadable
|
||
|
|
||
|
def call(report)
|
||
|
@report = report
|
||
|
|
||
|
forward_to_origin!
|
||
|
update_report!
|
||
|
end
|
||
|
|
||
|
private
|
||
|
|
||
|
def forward_to_origin!
|
||
|
ActivityPub::DeliveryWorker.perform_async(payload, some_local_account.id, @report.target_account.inbox_url)
|
||
|
end
|
||
|
|
||
|
def update_report!
|
||
|
@report.update(forwarded: true)
|
||
|
end
|
||
|
|
||
|
def payload
|
||
|
Oj.dump(serialize_payload(@report, ActivityPub::FlagSerializer, account: some_local_account))
|
||
|
end
|
||
|
|
||
|
def some_local_account
|
||
|
@some_local_account ||= Account.representative
|
||
|
end
|
||
|
end
|