2018-07-30 14:43:44 +08:00
|
|
|
module Jobs
|
|
|
|
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
|
2018-07-30 14:43:44 +08:00
|
|
|
extension = FastImage.type(Discourse.store.path_for(upload))
|
|
|
|
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
|