2019-05-03 06:17:27 +08:00
|
|
|
# frozen_string_literal: true
|
|
|
|
|
2018-07-30 14:43:44 +08:00
|
|
|
module Jobs
|
2019-10-02 12:01:53 +08:00
|
|
|
class FixInvalidGravatarUploads < ::Jobs::Onceoff
|
2018-07-30 15:07:03 +08:00
|
|
|
def execute_onceoff(args)
|
2018-07-30 14:43:44 +08:00
|
|
|
Upload.where(original_filename: "gravatar.png").find_each do |upload|
|
2018-10-16 07:29:16 +08:00
|
|
|
# note, this still feels pretty expensive for a once off
|
|
|
|
# we may need to re-evaluate this
|
2021-02-04 00:45:12 +08:00
|
|
|
extension = FastImage.type(Discourse.store.path_for(upload)) rescue nil
|
2018-07-30 14:43:44 +08:00
|
|
|
current_extension = upload.extension
|
|
|
|
|
|
|
|
if extension.to_s.downcase != current_extension.to_s.downcase
|
2018-10-16 07:29:16 +08:00
|
|
|
upload&.user&.user_avatar&.update_columns(last_gravatar_download_attempt: nil)
|
2018-07-30 14:43:44 +08:00
|
|
|
end
|
|
|
|
end
|
|
|
|
end
|
|
|
|
end
|
|
|
|
end
|