mirror of
https://github.com/discourse/discourse.git
synced 2025-05-21 18:12:32 +08:00
Update the destination category id when a user changes it
This commit is contained in:
@ -11,6 +11,7 @@ class TopicsController < ApplicationController
|
||||
:timings,
|
||||
:destroy_timings,
|
||||
:update,
|
||||
:update_shared_draft,
|
||||
:destroy,
|
||||
:recover,
|
||||
:status,
|
||||
@ -236,6 +237,17 @@ class TopicsController < ApplicationController
|
||||
render body: nil
|
||||
end
|
||||
|
||||
def update_shared_draft
|
||||
topic = Topic.find_by(id: params[:id])
|
||||
guardian.ensure_can_edit!(topic)
|
||||
guardian.ensure_can_create_shared_draft!
|
||||
raise Discourse::NotFound unless topic.shared_draft.present?
|
||||
|
||||
SharedDraft.where(topic_id: topic.id).update_all(category_id: params[:category_id].to_i)
|
||||
|
||||
render json: success_json
|
||||
end
|
||||
|
||||
def update
|
||||
topic = Topic.find_by(id: params[:topic_id])
|
||||
guardian.ensure_can_edit!(topic)
|
||||
|
Reference in New Issue
Block a user