0
0
Fork 0

Fix to be able to redownload avatar and header (#16190)

* Fix to reset if header and avatar download fails

* Add RedownloadAvatarWorker and RedownloadHeaderWorker
This commit is contained in:
Takeshi Umeda 2021-05-11 21:19:22 +09:00 committed by GitHub
parent b5ad787ebf
commit c403c3695b
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
6 changed files with 72 additions and 4 deletions

View file

@ -0,0 +1,29 @@
# 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? || 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