2019-05-03 06:17:27 +08:00
|
|
|
# frozen_string_literal: true
|
|
|
|
|
2017-05-11 06:16:57 +08:00
|
|
|
module Jobs
|
2019-10-02 12:01:53 +08:00
|
|
|
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
|
|
|
|
2020-10-16 18:41:27 +08:00
|
|
|
Discourse.avatar_sizes.each { |size| OptimizedImage.create_for(upload, size, size) }
|
2017-05-11 06:16:57 +08:00
|
|
|
end
|
|
|
|
end
|
|
|
|
end
|