mirror of
https://github.com/discourse/discourse.git
synced 2024-11-27 11:43:44 +08:00
c7b9f044a4
Staff and TL4 users can decide the slow mode duration. We'll internally set a topic timer to disable it.
25 lines
514 B
Ruby
25 lines
514 B
Ruby
# frozen_string_literal: true
|
|
|
|
module Jobs
|
|
class ClearSlowMode < ::Jobs::Base
|
|
|
|
def execute(args)
|
|
topic_timer = TopicTimer.find_by(id: args[:topic_timer_id] || args[:topic_status_update_id])
|
|
|
|
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
|