mirror of
https://github.com/discourse/discourse.git
synced 2025-05-22 22:43:33 +08:00
DEV: Apply syntax_tree formatting to app/*
This commit is contained in:
@ -9,15 +9,9 @@ class DraftsController < ApplicationController
|
||||
params.permit(:offset)
|
||||
params.permit(:limit)
|
||||
|
||||
stream = Draft.stream(
|
||||
user: current_user,
|
||||
offset: params[:offset],
|
||||
limit: params[:limit]
|
||||
)
|
||||
stream = Draft.stream(user: current_user, offset: params[:offset], limit: params[:limit])
|
||||
|
||||
render json: {
|
||||
drafts: stream ? serialize_data(stream, DraftSerializer) : []
|
||||
}
|
||||
render json: { drafts: stream ? serialize_data(stream, DraftSerializer) : [] }
|
||||
end
|
||||
|
||||
def show
|
||||
@ -38,10 +32,9 @@ class DraftsController < ApplicationController
|
||||
params[:sequence].to_i,
|
||||
params[:data],
|
||||
params[:owner],
|
||||
force_save: params[:force_save]
|
||||
force_save: params[:force_save],
|
||||
)
|
||||
rescue Draft::OutOfSequence
|
||||
|
||||
begin
|
||||
if !Draft.exists?(user_id: current_user.id, draft_key: params[:draft_key])
|
||||
Draft.set(
|
||||
@ -49,18 +42,17 @@ class DraftsController < ApplicationController
|
||||
params[:draft_key],
|
||||
DraftSequence.current(current_user, params[:draft_key]),
|
||||
params[:data],
|
||||
params[:owner]
|
||||
params[:owner],
|
||||
)
|
||||
else
|
||||
raise Draft::OutOfSequence
|
||||
end
|
||||
|
||||
rescue Draft::OutOfSequence
|
||||
render_json_error I18n.t('draft.sequence_conflict_error.title'),
|
||||
status: 409,
|
||||
extras: {
|
||||
description: I18n.t('draft.sequence_conflict_error.description')
|
||||
}
|
||||
render_json_error I18n.t("draft.sequence_conflict_error.title"),
|
||||
status: 409,
|
||||
extras: {
|
||||
description: I18n.t("draft.sequence_conflict_error.description"),
|
||||
}
|
||||
return
|
||||
end
|
||||
end
|
||||
@ -68,7 +60,7 @@ class DraftsController < ApplicationController
|
||||
json = success_json.merge(draft_sequence: sequence)
|
||||
|
||||
begin
|
||||
data = JSON::parse(params[:data])
|
||||
data = JSON.parse(params[:data])
|
||||
rescue JSON::ParserError
|
||||
raise Discourse::InvalidParameters.new(:data)
|
||||
end
|
||||
@ -76,7 +68,8 @@ class DraftsController < ApplicationController
|
||||
if data.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")
|
||||
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)
|
||||
|
Reference in New Issue
Block a user