2018-07-30 01:43:44 -05:00
|
|
|
module Jobs
|
|
|
|
class FixInvalidGravatarUploads < Jobs::Onceoff
|
2018-07-30 02:07:03 -05:00
|
|
|
def execute_onceoff(args)
|
2018-07-30 01:43:44 -05:00
|
|
|
Upload.where(original_filename: "gravatar.png").find_each do |upload|
|
2018-10-15 18:29:16 -05:00
|
|
|
# note, this still feels pretty expensive for a once off
|
|
|
|
# we may need to re-evaluate this
|
2018-07-30 01:43:44 -05: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-15 18:29:16 -05:00
|
|
|
upload&.user&.user_avatar&.update_columns(last_gravatar_download_attempt: nil)
|
2018-07-30 01:43:44 -05:00
|
|
|
end
|
|
|
|
end
|
|
|
|
end
|
|
|
|
end
|
|
|
|
end
|