mirror of
https://github.com/discourse/discourse.git
synced 2024-12-03 05:03:44 +08:00
2404fa7a23
Splits the `ToggleTopicClosed` job into two distinct `OpenTopic` and `CloseTopic` jobs to make the code clearer. The old job cannot be deleted yet because of outstanding sidekiq schedules, so a todo has been added to do so later this year. Also replaced mentions of `topic_status_update` with `topic_timer` in some files, because the `topic_status_update` model is obsolete and replaced by topic timer. Added some shortcut methods for checking if a topic is open/whether a user can change an open topic.
25 lines
481 B
Ruby
25 lines
481 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])
|
|
|
|
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
|