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