mirror of
https://github.com/lunaisnotaboy/mastodon.git
synced 2024-09-11 20:57:44 +00:00
34 lines
856 B
Ruby
34 lines
856 B
Ruby
# frozen_string_literal: true
|
|
|
|
class ActivityPub::UpdateDistributionWorker
|
|
include Sidekiq::Worker
|
|
include Payloadable
|
|
|
|
sidekiq_options queue: 'push'
|
|
|
|
def perform(account_id, options = {})
|
|
@options = options.with_indifferent_access
|
|
@account = Account.find(account_id)
|
|
|
|
ActivityPub::DeliveryWorker.push_bulk(inboxes) do |inbox_url|
|
|
[signed_payload, @account.id, inbox_url]
|
|
end
|
|
|
|
ActivityPub::DeliveryWorker.push_bulk(Relay.enabled.pluck(:inbox_url)) do |inbox_url|
|
|
[signed_payload, @account.id, inbox_url]
|
|
end
|
|
rescue ActiveRecord::RecordNotFound
|
|
true
|
|
end
|
|
|
|
private
|
|
|
|
def inboxes
|
|
@inboxes ||= @account.followers.inboxes
|
|
end
|
|
|
|
def signed_payload
|
|
@signed_payload ||= Oj.dump(serialize_payload(@account, ActivityPub::UpdateSerializer, signer: @account, sign_with: @options[:sign_with]))
|
|
end
|
|
end
|