mirror of
https://github.com/discourse/discourse.git
synced 2025-02-25 18:55:32 -06:00
FEATURE: auto-close topics based on last post
This commit is contained in:
@@ -178,12 +178,20 @@ class TopicsController < ApplicationController
|
||||
end
|
||||
|
||||
def autoclose
|
||||
raise Discourse::InvalidParameters.new(:auto_close_time) unless params.has_key?(:auto_close_time)
|
||||
params.permit(:auto_close_time)
|
||||
params.require(:auto_close_based_on_last_post)
|
||||
|
||||
topic = Topic.find_by(id: params[:topic_id].to_i)
|
||||
guardian.ensure_can_moderate!(topic)
|
||||
|
||||
topic.auto_close_based_on_last_post = params[:auto_close_based_on_last_post]
|
||||
topic.set_auto_close(params[:auto_close_time], current_user)
|
||||
|
||||
if topic.save
|
||||
render json: success_json.merge!(auto_close_at: topic.auto_close_at)
|
||||
render json: success_json.merge!({
|
||||
auto_close_at: topic.auto_close_at,
|
||||
auto_close_hours: topic.auto_close_hours
|
||||
})
|
||||
else
|
||||
render_json_error(topic)
|
||||
end
|
||||
|
||||
Reference in New Issue
Block a user