2013-02-06 03:16:51 +08:00
|
|
|
module Jobs
|
|
|
|
|
|
|
|
class FeatureTopicUsers < Jobs::Base
|
|
|
|
|
|
|
|
def execute(args)
|
2013-04-18 07:34:58 +08:00
|
|
|
topic_id = args[:topic_id]
|
|
|
|
raise Discourse::InvalidParameters.new(:topic_id) unless topic_id.present?
|
|
|
|
|
2014-05-06 21:41:59 +08:00
|
|
|
topic = Topic.find_by(id: topic_id)
|
2013-04-18 07:34:58 +08:00
|
|
|
|
|
|
|
# there are 3 cases here
|
|
|
|
# 1. topic was atomically nuked, this should be skipped
|
|
|
|
# 2. topic was deleted, this should be skipped
|
|
|
|
# 3. error an incorrect topic_id was sent
|
|
|
|
|
|
|
|
unless topic.present?
|
|
|
|
max_id = Topic.with_deleted.maximum(:id).to_i
|
|
|
|
raise Discourse::InvalidParameters.new(:topic_id) if max_id < topic_id
|
|
|
|
return
|
|
|
|
end
|
2013-02-06 03:16:51 +08:00
|
|
|
|
2013-03-13 00:33:42 +08:00
|
|
|
topic.feature_topic_users(args)
|
2013-02-06 03:16:51 +08:00
|
|
|
end
|
|
|
|
|
|
|
|
end
|
|
|
|
|
|
|
|
end
|