2019-05-02 17:17:27 -05:00
|
|
|
# frozen_string_literal: true
|
|
|
|
|
2017-05-10 17:16:57 -05:00
|
|
|
module Jobs
|
|
|
|
|
2019-10-01 23:01:53 -05:00
|
|
|
class CreateAvatarThumbnails < ::Jobs::Base
|
2018-08-07 03:05:13 -05:00
|
|
|
sidekiq_options queue: 'low'
|
2017-05-10 17:16:57 -05:00
|
|
|
|
|
|
|
def execute(args)
|
2017-06-21 21:23:31 -05:00
|
|
|
return if Rails.env.test?
|
2017-05-10 17:16:57 -05:00
|
|
|
upload_id = args[:upload_id]
|
|
|
|
|
|
|
|
raise Discourse::InvalidParameters.new(:upload_id) if upload_id.blank?
|
|
|
|
|
2017-05-11 02:07:04 -05:00
|
|
|
return unless upload = Upload.find_by(id: upload_id)
|
2017-05-10 17:16:57 -05:00
|
|
|
|
|
|
|
Discourse.avatar_sizes.each do |size|
|
2018-08-16 01:32:36 -05:00
|
|
|
OptimizedImage.create_for(
|
|
|
|
upload,
|
|
|
|
size,
|
|
|
|
size,
|
|
|
|
allow_animation: SiteSetting.allow_animated_avatars
|
|
|
|
)
|
2017-05-10 17:16:57 -05:00
|
|
|
end
|
|
|
|
end
|
|
|
|
|
|
|
|
end
|
|
|
|
|
|
|
|
end
|