FEATURE: Per-category default slow mode duration for topics.

When configured, all topics in the category inherits the slow mode
duration from the category's default.

Note that currently there is no way to remove the slow mode from the
topics once it has been set.
This commit is contained in:
mintsaxon
2021-06-27 21:46:11 +02:00
committed by Alan Guo Xiang Tan
parent 0ea58fe51f
commit 7162ecfb04
12 changed files with 62 additions and 2 deletions

View File

@@ -334,6 +334,7 @@ class Topic < ActiveRecord::Base
if category_id_changed? || new_record?
inherit_auto_close_from_category
inherit_slow_mode_from_category
end
end
@@ -1251,6 +1252,12 @@ class Topic < ActiveRecord::Base
end
end
def inherit_slow_mode_from_category
if self.category&.default_slow_mode_seconds
self.slow_mode_seconds = self.category&.default_slow_mode_seconds
end
end
def inherit_auto_close_from_category(timer_type: :close)
auto_close_hours = self.category&.auto_close_hours