mirror of
https://github.com/discourse/discourse.git
synced 2025-05-22 06:41:25 +08:00
FIX: Topic timers being incorrectly trashed!
.
https://meta.discourse.org/t/temporary-timed-closure-of-topic-not-re-opening-topic/67877
This commit is contained in:
@ -994,6 +994,12 @@ SQL
|
||||
@public_topic_timer ||= topic_timers.find_by(deleted_at: nil, public_type: true)
|
||||
end
|
||||
|
||||
def delete_topic_timer(status_type, by_user: Discourse.system_user)
|
||||
options = { status_type: status_type }
|
||||
options.merge!(user: by_user) unless TopicTimer.public_types[status_type]
|
||||
self.topic_timers.find_by(options)&.trash!(by_user)
|
||||
end
|
||||
|
||||
# Valid arguments for the time:
|
||||
# * An integer, which is the number of hours from now to update the topic's status.
|
||||
# * A timestamp, like "2013-11-25 13:00", when the topic's status should update.
|
||||
@ -1005,16 +1011,13 @@ SQL
|
||||
# * based_on_last_post: True if time should be based on timestamp of the last post.
|
||||
# * category_id: Category that the update will apply to.
|
||||
def set_or_create_timer(status_type, time, by_user: nil, timezone_offset: 0, based_on_last_post: false, category_id: SiteSetting.uncategorized_category_id)
|
||||
return delete_topic_timer(status_type, by_user: by_user) if time.blank?
|
||||
|
||||
topic_timer_options = { topic: self }
|
||||
topic_timer_options.merge!(user: by_user) unless TopicTimer.public_types[status_type]
|
||||
topic_timer = TopicTimer.find_or_initialize_by(topic_timer_options)
|
||||
topic_timer.status_type = status_type
|
||||
|
||||
if time.blank?
|
||||
topic_timer.trash!(by_user || Discourse.system_user)
|
||||
return
|
||||
end
|
||||
|
||||
time_now = Time.zone.now
|
||||
topic_timer.based_on_last_post = !based_on_last_post.blank?
|
||||
|
||||
|
Reference in New Issue
Block a user