Skip to content

A platform for community discussion. Free, open, simple.

FIX: only check for conflict on edit drafts

Sam6556a8762912
diff --git a/app/controllers/draft_controller.rb b/app/controllers/draft_controller.rb
index 34b55c7ad82..cd5a7ef09e0 100644
--- a/app/controllers/draft_controller.rb
+++ b/app/controllers/draft_controller.rb
@@ -12,7 +12,9 @@ class DraftController < ApplicationController
Draft.set(current_user, params[:draft_key], params[:sequence].to_i, params[:data])
if data = JSON::parse(params[:data])
- if data["postId"].present? && data["originalText"].present?
+ # this is a bit of a kludge we need to remove (all the parsing) too many special cases here
+ # we need to catch action edit and action editSharedDraft
+ if data["postId"].present? && data["originalText"].present? && data["action"].to_s.start_with?("edit")
post = Post.find_by(id: data["postId"])
if post && post.raw != data["originalText"]
conflict_user = BasicUserSerializer.new(post.last_editor, root: false)
diff --git a/spec/requests/draft_controller_spec.rb b/spec/requests/draft_controller_spec.rb
index b00e7be0383..633f57cbda7 100644
--- a/spec/requests/draft_controller_spec.rb
+++ b/spec/requests/draft_controller_spec.rb
@@ -29,7 +29,8 @@ describe DraftController do
sequence: 0,
data: {
postId: post.id,
- originalText: post.raw
+ originalText: post.raw,
+ action: "edit"
}.to_json
}
@@ -41,7 +42,8 @@ describe DraftController do
sequence: 0,
data: {
postId: post.id,
- originalText: "something else"
+ originalText: "something else",
+ action: "edit"
}.to_json
}