2020-12-14 12:06:50 -05:00
|
|
|
# frozen_string_literal: true
|
|
|
|
|
|
|
|
module Jobs
|
|
|
|
class ClearSlowMode < ::Jobs::Base
|
|
|
|
|
|
|
|
def execute(args)
|
2021-01-12 17:49:29 -05:00
|
|
|
topic_timer = TopicTimer.find_by(id: args[:topic_timer_id])
|
2020-12-14 12:06:50 -05:00
|
|
|
|
|
|
|
if topic_timer.nil? || topic_timer.execute_at > Time.zone.now
|
|
|
|
return
|
|
|
|
end
|
|
|
|
|
|
|
|
topic = topic_timer&.topic
|
|
|
|
|
|
|
|
if topic.nil?
|
|
|
|
topic_timer.destroy!
|
|
|
|
return
|
|
|
|
end
|
|
|
|
|
|
|
|
topic.update!(slow_mode_seconds: 0)
|
|
|
|
topic_timer.trash!(Discourse.system_user)
|
|
|
|
end
|
|
|
|
end
|
|
|
|
end
|