FIX: Don't raise an error if TopicStatusUpdate has been deleted.

This commit is contained in:
Guo Xiang Tan 2017-04-04 14:29:47 +08:00
parent 406d721f11
commit 69661be500

View File

@ -2,15 +2,15 @@ module Jobs
class ToggleTopicClosed < Jobs::Base
def execute(args)
topic_status_update = TopicStatusUpdate.find_by(id: args[:topic_status_update_id])
raise Discourse::InvalidParameters.new(:topic_status_update_id) if topic_status_update.blank?
return if topic_status_update.execute_at > Time.zone.now
topic = topic_status_update.topic
return if topic.blank?
state = !!args[:state]
return if topic.closed == state
if topic_status_update.blank? ||
topic_status_update.execute_at > Time.zone.now ||
(topic = topic_status_update.topic).blank? ||
topic.closed == state
return
end
user = topic_status_update.user