0
0
Fork 0
mirror of https://github.com/discourse/discourse.git synced 2026-08-04 10:39:43 +08:00
discourse/app/jobs/regular/close_topic.rb
Mark VanLandingham 1171b86bb7
FEATURE: Allow topic_timers_allowed_groups to manage topic timers (#41126)
Previously managing topic timers was staff + TL4 only. This moves the
logic to a group site setting so that other groups can set timers.
2026-06-23 12:46:56 -05:00

35 lines
871 B
Ruby
Vendored

# frozen_string_literal: true
module Jobs
class CloseTopic < ::Jobs::TopicTimerBase
def execute_timer_action(topic_timer, topic)
silent = @args[:silent]
user = topic_timer.user
if topic.closed?
topic_timer.destroy!
return
end
if !Guardian.new(user).can_set_topic_timer?(topic)
topic_timer.destroy!
topic.reload
if topic_timer.based_on_last_post
topic.inherit_auto_close_from_category(timer_type: silent ? :silent_close : :close)
end
return
end
# this handles deleting the topic timer as well, see TopicStatusUpdater
topic.update_status("autoclosed", true, user, { silent: silent })
MessageBus.publish(
"/topic/#{topic.id}",
{ reload_topic: true },
topic.secure_audience_publish_messages,
)
end
end
end