nas/app/workers/redownload_header_worker.rb
KMY(雪あすか) 0f680a21b4
Add: ホワイトリスト運用時、承認待ちリモートアカウントの概念ならびに操作画面 (#584)
* Add: ホワイトリスト運用時、承認待ちリモートアカウントの概念ならびに操作画面

* Fix test

* Fix test
2024-02-17 21:07:37 +09:00

29 lines
712 B
Ruby

# frozen_string_literal: true
class RedownloadHeaderWorker
include Sidekiq::Worker
include ExponentialBackoff
include JsonLdHelper
sidekiq_options queue: 'pull', retry: 7
def perform(id)
account = Account.find(id)
return if (account.suspended? && !account.remote_pending) || DomainBlock.rule_for(account.domain)&.reject_media?
return if account.header_remote_url.blank? || account.header_file_name.present?
account.reset_header!
account.save!
rescue ActiveRecord::RecordNotFound
# Do nothing
rescue Mastodon::UnexpectedResponseError => e
response = e.response
if response_error_unsalvageable?(response)
# Give up
else
raise e
end
end
end