2017-08-12 22:44:41 +00:00
|
|
|
# frozen_string_literal: true
|
|
|
|
|
2022-01-19 21:37:27 +00:00
|
|
|
class ActivityPub::DistributionWorker < ActivityPub::RawDistributionWorker
|
|
|
|
# Distribute a new status or an edit of a status to all the places
|
|
|
|
# where the status is supposed to go or where it was interacted with
|
2017-08-12 22:44:41 +00:00
|
|
|
def perform(status_id)
|
|
|
|
@status = Status.find(status_id)
|
|
|
|
@account = @status.account
|
|
|
|
|
2022-01-19 21:37:27 +00:00
|
|
|
distribute!
|
2017-08-12 22:44:41 +00:00
|
|
|
rescue ActiveRecord::RecordNotFound
|
|
|
|
true
|
|
|
|
end
|
|
|
|
|
2022-01-19 21:37:27 +00:00
|
|
|
protected
|
2018-07-13 00:16:06 +00:00
|
|
|
|
2017-08-12 22:44:41 +00:00
|
|
|
def inboxes
|
2022-01-19 21:37:27 +00:00
|
|
|
@inboxes ||= StatusReachFinder.new(@status).inboxes
|
2017-08-12 22:44:41 +00:00
|
|
|
end
|
|
|
|
|
2018-12-30 08:48:59 +00:00
|
|
|
def payload
|
2022-01-19 21:37:27 +00:00
|
|
|
@payload ||= Oj.dump(serialize_payload(activity, ActivityPub::ActivitySerializer, signer: @account))
|
|
|
|
end
|
|
|
|
|
|
|
|
def activity
|
|
|
|
ActivityPub::ActivityPresenter.from_status(@status)
|
2018-12-30 08:48:59 +00:00
|
|
|
end
|
|
|
|
|
2022-01-19 21:37:27 +00:00
|
|
|
def options
|
2022-01-27 23:43:56 +00:00
|
|
|
{ 'synchronize_followers' => @status.private_visibility? }
|
2018-07-13 00:16:06 +00:00
|
|
|
end
|
2017-08-12 22:44:41 +00:00
|
|
|
end
|