mirror of
https://github.com/discourse/discourse.git
synced 2025-05-22 19:02:40 +08:00
FEATURE: Topic slow mode. (#10904)
Adds a new slow mode for topics that are heating up. Users will have to wait for a period of time before being able to post again. We store this interval inside the topics table and track the last time a user posted using the last_posted_at datetime in the TopicUser relation.
This commit is contained in:
@ -28,7 +28,8 @@ class TopicsController < ApplicationController
|
||||
:convert_topic,
|
||||
:bookmark,
|
||||
:publish,
|
||||
:reset_bump_date
|
||||
:reset_bump_date,
|
||||
:set_slow_mode
|
||||
]
|
||||
|
||||
before_action :consider_user_for_promotion, only: :show
|
||||
@ -932,6 +933,15 @@ class TopicsController < ApplicationController
|
||||
render body: nil
|
||||
end
|
||||
|
||||
def set_slow_mode
|
||||
topic = Topic.find(params[:topic_id])
|
||||
|
||||
guardian.ensure_can_moderate!(topic)
|
||||
topic.update!(slow_mode_seconds: params[:seconds])
|
||||
|
||||
head :ok
|
||||
end
|
||||
|
||||
private
|
||||
|
||||
def topic_params
|
||||
|
Reference in New Issue
Block a user