remote_account_refresh_worker.rb 532 B

123456789101112131415161718192021222324
  1. # frozen_string_literal: true
  2. class RemoteAccountRefreshWorker
  3. include Sidekiq::Worker
  4. include ExponentialBackoff
  5. include JsonLdHelper
  6. sidekiq_options queue: 'pull', retry: 3
  7. def perform(id)
  8. account = Account.find_by(id: id)
  9. return if account.nil? || account.local?
  10. ActivityPub::FetchRemoteAccountService.new.call(account.uri)
  11. rescue Mastodon::UnexpectedResponseError => e
  12. response = e.response
  13. if response_error_unsalvageable?(response)
  14. # Give up
  15. else
  16. raise e
  17. end
  18. end
  19. end