mirror of
https://github.com/discourse/discourse.git
synced 2024-11-30 23:48:34 +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.
23 lines
547 B
Ruby
23 lines
547 B
Ruby
# frozen_string_literal: true
|
|
|
|
module Jobs
|
|
class BumpTopic < ::Jobs::Base
|
|
|
|
def execute(args)
|
|
topic_timer = TopicTimer.find_by(id: args[:topic_timer_id])
|
|
|
|
topic = topic_timer&.topic
|
|
|
|
if topic_timer.blank? || topic.blank? || topic_timer.execute_at > Time.zone.now
|
|
return
|
|
end
|
|
|
|
if Guardian.new(topic_timer.user).can_create_post_on_topic?(topic)
|
|
topic.add_small_action(Discourse.system_user, "autobumped", nil, bump: true)
|
|
end
|
|
topic_timer.trash!(Discourse.system_user)
|
|
end
|
|
|
|
end
|
|
end
|