mirror of
https://github.com/discourse/discourse.git
synced 2024-11-22 08:57:10 -06:00
FIX: only check for conflict on edit drafts
In some unknown cases non edit drafts are being checked for conflict
This commit is contained in:
parent
ee60ecc71f
commit
6556a87629
@ -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)
|
||||
|
@ -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
|
||||
}
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user