about summary refs log tree commit diff
path: root/app/workers/fetch_reply_worker.rb
blob: 67db042fd080d423d6e0c34f3891cc1688ad3242 (plain) (blame)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
# frozen_string_literal: true

class FetchReplyWorker
  include Sidekiq::Worker
  include ExponentialBackoff

  sidekiq_options queue: 'pull', retry: 3

  def perform(child_url, account_id = nil)
    account = account_id.blank? ? nil : Account.find_by(id: account_id)
    on_behalf_of = account.blank? ? nil : account.followers.local.random.first

    FetchRemoteStatusService.new.call(child_url, nil, on_behalf_of)
  rescue ActiveRecord::RecordNotFound
    nil
  end
end