Refactor StatusReachFinder to be used in more places

This commit is contained in:
Eugen Rochko 2021-09-25 00:17:36 +02:00
parent c99d28369a
commit ce463ccb50
13 changed files with 321 additions and 99 deletions

View file

@ -5,9 +5,36 @@ class ActivityPub::ProcessingWorker
sidekiq_options backtrace: true, retry: 8
def perform(account_id, body, delivered_to_account_id = nil)
ActivityPub::ProcessCollectionService.new.call(body, Account.find(account_id), override_timestamps: true, delivered_to_account_id: delivered_to_account_id, delivery: true)
def perform(account_id, body, delivered_to_account_id = nil, headers = {})
@account = Account.find(account_id)
@body = body
@delivered_to_account_id = delivered_to_account_id
@headers = headers
process_collection_synchronization!
process_collection!
rescue ActiveRecord::RecordInvalid => e
Rails.logger.debug "Error processing incoming ActivityPub object: #{e}"
Rails.logger.debug "Error processing incoming ActivityPub payload: #{e}"
end
private
def process_collection_synchronization!
collection_synchronization = @headers['Collection-Synchronization']
return if collection_synchronization.blank?
ActivityPub::ProcessCollectionSynchronizationService.new.call(@account, collection_synchronization)
end
def process_collection!
ActivityPub::ProcessCollectionService.new.call(
@body,
@account,
override_timestamps: true,
delivered_to_account_id: @delivered_to_account_id,
delivery: true,
headers: @headers
)
end
end