about summary refs log tree commit diff
path: root/app/workers/remote_account_refresh_worker.rb
blob: 9632936b54712c0a2484a7c95f98a7c471dee014 (plain) (blame)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
# frozen_string_literal: true

class RemoteAccountRefreshWorker
  include Sidekiq::Worker
  include ExponentialBackoff
  include JsonLdHelper

  sidekiq_options queue: 'pull', retry: 3

  def perform(id)
    account = Account.find_by(id: id)
    return if account.nil? || account.local?

    ActivityPub::FetchRemoteAccountService.new.call(account.uri)
  rescue Mastodon::UnexpectedResponseError => e
    response = e.response

    if response_error_unsalvageable?(response)
      # Give up
    else
      raise e
    end
  end
end