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