mirror of
https://github.com/discourse/discourse.git
synced 2025-03-22 20:05:32 +08: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])
|
Draft.set(current_user, params[:draft_key], params[:sequence].to_i, params[:data])
|
||||||
|
|
||||||
if data = JSON::parse(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"])
|
post = Post.find_by(id: data["postId"])
|
||||||
if post && post.raw != data["originalText"]
|
if post && post.raw != data["originalText"]
|
||||||
conflict_user = BasicUserSerializer.new(post.last_editor, root: false)
|
conflict_user = BasicUserSerializer.new(post.last_editor, root: false)
|
||||||
|
@ -29,7 +29,8 @@ describe DraftController do
|
|||||||
sequence: 0,
|
sequence: 0,
|
||||||
data: {
|
data: {
|
||||||
postId: post.id,
|
postId: post.id,
|
||||||
originalText: post.raw
|
originalText: post.raw,
|
||||||
|
action: "edit"
|
||||||
}.to_json
|
}.to_json
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -41,7 +42,8 @@ describe DraftController do
|
|||||||
sequence: 0,
|
sequence: 0,
|
||||||
data: {
|
data: {
|
||||||
postId: post.id,
|
postId: post.id,
|
||||||
originalText: "something else"
|
originalText: "something else",
|
||||||
|
action: "edit"
|
||||||
}.to_json
|
}.to_json
|
||||||
}
|
}
|
||||||
|
|
||||||
|
Loading…
x
Reference in New Issue
Block a user