discourse/app/jobs/regular/generate_topic_thumbnails.rb
Rafael dos Santos Silva 4d137b4f89
FIX: Handle a deleted topic in thumbnail generation
Follow up to 03818e642a

A topic can be deleted between job enqueue and job execution
2020-05-11 13:32:37 -03:00

19 lines
422 B
Ruby

# frozen_string_literal: true
module Jobs
class GenerateTopicThumbnails < ::Jobs::Base
sidekiq_options queue: 'ultra_low'
def execute(args)
topic_id = args[:topic_id]
extra_sizes = args[:extra_sizes]
raise Discourse::InvalidParameters.new(:topic_id) if topic_id.blank?
topic = Topic.find_by(id: topic_id)
topic&.generate_thumbnails!(extra_sizes: extra_sizes)
end
end
end