mirror of
https://github.com/discourse/discourse.git
synced 2025-05-28 13:51:18 +08:00
FEATURE: Allow moderators to change topic timestamps (#7053)
This commit is contained in:
@ -676,17 +676,22 @@ class TopicsController < ApplicationController
|
||||
end
|
||||
|
||||
def change_timestamps
|
||||
params.require(:topic_id)
|
||||
params.require(:timestamp)
|
||||
topic_id = params.require(:topic_id).to_i
|
||||
timestamp = params.require(:timestamp).to_f
|
||||
|
||||
guardian.ensure_can_change_post_timestamps!
|
||||
|
||||
topic = Topic.with_deleted.find(topic_id)
|
||||
previous_timestamp = topic.first_post.created_at
|
||||
|
||||
begin
|
||||
TopicTimestampChanger.new(
|
||||
topic_id: params[:topic_id].to_i,
|
||||
timestamp: params[:timestamp].to_f
|
||||
topic: topic,
|
||||
timestamp: timestamp
|
||||
).change!
|
||||
|
||||
StaffActionLogger.new(current_user).log_topic_timestamps_changed(topic, Time.zone.at(timestamp), previous_timestamp)
|
||||
|
||||
render json: success_json
|
||||
rescue ActiveRecord::RecordInvalid, TopicTimestampChanger::InvalidTimestampError
|
||||
render json: failed_json, status: 422
|
||||
|
Reference in New Issue
Block a user