redownload_header_worker.rb 683 B

1234567891011121314151617181920212223242526272829
  1. # frozen_string_literal: true
  2. class RedownloadHeaderWorker
  3. include Sidekiq::Worker
  4. include ExponentialBackoff
  5. include JsonLdHelper
  6. sidekiq_options queue: 'pull', retry: 7
  7. def perform(id)
  8. account = Account.find(id)
  9. return if account.suspended? || DomainBlock.rule_for(account.domain)&.reject_media?
  10. return if account.header_remote_url.blank? || account.header_file_name.present?
  11. account.reset_header!
  12. account.save!
  13. rescue ActiveRecord::RecordNotFound
  14. # Do nothing
  15. rescue Mastodon::UnexpectedResponseError => e
  16. response = e.response
  17. if response_error_unsalvageable?(response)
  18. # Give up
  19. else
  20. raise e
  21. end
  22. end
  23. end