about summary refs log tree commit diff
path: root/app/workers/activitypub/process_collection_items_for_account_worker.rb
blob: 4b5710c1ddf005b3c04f10d53049ce59f130125f (plain) (blame)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
# frozen_string_literal: true
class ActivityPub::ProcessCollectionItemsForAccountWorker
  include Sidekiq::Worker

  sidekiq_options queue: 'pull', retry: 3

  def perform(account_id)
    @account_id = account_id
    on_behalf_of = nil

    if account_id.present?
      account = Account.find(account_id)
      on_behalf_of = account.followers.local.random.first
    end

    ActivityPub::ProcessCollectionItemsService.new.call(account_id, on_behalf_of)
  rescue ActiveRecord::RecordNotFound
    nil
  end
end