diff --git a/app/controllers/posts_controller.rb b/app/controllers/posts_controller.rb index 2d420907f90..1bc426c10dc 100644 --- a/app/controllers/posts_controller.rb +++ b/app/controllers/posts_controller.rb @@ -40,11 +40,28 @@ class PostsController < ApplicationController post.image_sizes = params[:image_sizes] if params[:image_sizes].present? guardian.ensure_can_edit!(post) + # to stay consistent with the create api, + # we should allow for title changes and category changes here + # we should also move all of this to a post updater. + if post.post_number == 1 && (params[:title] || params[:post][:category]) + post.topic.title = params[:title] if params[:title] + Topic.transaction do + post.topic.change_category(params[:post][:category]) + post.topic.save + end + + if post.topic.errors.present? + render_json_error(post.topic) + return + end + end + revisor = PostRevisor.new(post) if revisor.revise!(current_user, params[:post][:raw]) TopicLink.extract_from(post) end + if post.errors.present? render_json_error(post) return