Class: Jobs::OpenTopic
- Inherits:
-
TopicTimerBase
- Object
- Base
- TopicTimerBase
- Jobs::OpenTopic
- Defined in:
- app/jobs/regular/open_topic.rb
Instance Method Summary collapse
Methods inherited from TopicTimerBase
Methods inherited from Base
acquire_cluster_concurrency_lock!, clear_cluster_concurrency_lock!, cluster_concurrency, cluster_concurrency_redis_key, delayed_perform, #error_context, #execute, get_cluster_concurrency, #last_db_duration, #log, #perform, #perform_immediately
Instance Method Details
#execute_timer_action(topic_timer, topic) ⇒ Object
5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 |
# File 'app/jobs/regular/open_topic.rb', line 5 def execute_timer_action(topic_timer, topic) user = topic_timer.user if !Guardian.new(user).can_open_topic?(topic) || topic.open? topic_timer.destroy! topic.reload topic.inherit_auto_close_from_category(timer_type: :close) return end # guards against reopening a topic too early if the topic has # been auto closed because of reviewables/reports, this will # just update the existing topic timer and push it down the line if topic.auto_close_threshold_reached? topic.set_or_create_timer( TopicTimer.types[:open], SiteSetting.num_hours_to_close_topic, by_user: Discourse.system_user, ) else # autoclosed, false is just another way of saying open. # this handles deleting the topic timer as well, see TopicStatusUpdater topic.update_status("autoclosed", false, user) end topic.inherit_auto_close_from_category(timer_type: :close) MessageBus.publish("/topic/#{topic.id}", reload_topic: true) end |