mirror of
https://github.com/discourse/discourse.git
synced 2025-06-05 08:07:17 +08:00
FEATURE: move a topic from PM to regular topic or vice versa
This commit is contained in:
@ -27,6 +27,7 @@ class TopicsController < ApplicationController
|
||||
:change_timestamps,
|
||||
:archive_message,
|
||||
:move_to_inbox,
|
||||
:convert_topic,
|
||||
:bookmark]
|
||||
|
||||
before_filter :consider_user_for_promotion, only: :show
|
||||
@ -510,6 +511,22 @@ class TopicsController < ApplicationController
|
||||
render nothing: true
|
||||
end
|
||||
|
||||
def convert_topic
|
||||
params.require(:id)
|
||||
params.require(:type)
|
||||
topic = Topic.find_by(id: params[:id])
|
||||
guardian.ensure_can_convert_topic!(topic)
|
||||
|
||||
if params[:type] == "public"
|
||||
converted_topic = topic.convert_to_public_topic(current_user)
|
||||
else
|
||||
converted_topic = topic.convert_to_private_message(current_user)
|
||||
end
|
||||
render_topic_changes(converted_topic)
|
||||
rescue ActiveRecord::RecordInvalid => ex
|
||||
render_json_error(ex)
|
||||
end
|
||||
|
||||
private
|
||||
|
||||
def toggle_mute
|
||||
|
Reference in New Issue
Block a user