mirror of
https://github.com/discourse/discourse.git
synced 2026-08-11 13:35:20 -05:00
Experimental: Interface to Move Posts to an Existing Topic
This commit is contained in:
@@ -127,18 +127,22 @@ class TopicsController < ApplicationController
|
||||
end
|
||||
|
||||
def move_posts
|
||||
requires_parameters(:title, :post_ids)
|
||||
requires_parameters(:post_ids)
|
||||
|
||||
topic = Topic.where(id: params[:topic_id]).first
|
||||
guardian.ensure_can_move_posts!(topic)
|
||||
|
||||
# Move the posts
|
||||
new_topic = topic.move_posts(current_user, params[:title], params[:post_ids].map {|p| p.to_i})
|
||||
args = {}
|
||||
args[:title] = params[:title] if params[:title].present?
|
||||
args[:destination_topic_id] = params[:destination_topic_id].to_i if params[:destination_topic_id].present?
|
||||
|
||||
if new_topic.present?
|
||||
render json: {success: true, url: new_topic.relative_url}
|
||||
dest_topic = topic.move_posts(current_user, params[:post_ids].map {|p| p.to_i}, args)
|
||||
if dest_topic.present?
|
||||
render json: {success: true, url: dest_topic.relative_url}
|
||||
else
|
||||
render json: {success: false}
|
||||
end
|
||||
|
||||
end
|
||||
|
||||
def clear_pin
|
||||
|
||||
Reference in New Issue
Block a user