FIX: Can't update status_type of topic timers.

https://meta.discourse.org/t/topic-timers-internal-error-500/64805
This commit is contained in:
Guo Xiang Tan
2017-06-21 15:31:15 +09:00
parent dd85c1098b
commit 4c98bd9d5f
3 changed files with 15 additions and 3 deletions

View File

@@ -988,9 +988,10 @@ 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)
topic_timer_options = { status_type: status_type, topic: self }
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!(trashed_by: by_user || Discourse.system_user)