mirror of
https://github.com/discourse/discourse.git
synced 2025-06-05 23:44:48 +08:00
raise error early in drafts controller
This commit is contained in:
@ -10,27 +10,27 @@ class DraftsController < ApplicationController
|
|||||||
|
|
||||||
user = fetch_user_from_params
|
user = fetch_user_from_params
|
||||||
|
|
||||||
|
unless user == current_user
|
||||||
|
raise Discourse::InvalidAccess
|
||||||
|
end
|
||||||
|
|
||||||
opts = {
|
opts = {
|
||||||
user: user,
|
user: user,
|
||||||
offset: params[:offset],
|
offset: params[:offset],
|
||||||
limit: params[:limit]
|
limit: params[:limit]
|
||||||
}
|
}
|
||||||
|
|
||||||
if user == current_user
|
stream = Draft.stream(opts)
|
||||||
stream = Draft.stream(opts)
|
stream.each do |d|
|
||||||
stream.each do |d|
|
parsed_data = JSON.parse(d.data)
|
||||||
parsed_data = JSON.parse(d.data)
|
if parsed_data
|
||||||
if parsed_data
|
if parsed_data['reply']
|
||||||
if parsed_data['reply']
|
d.raw = parsed_data['reply']
|
||||||
d.raw = parsed_data['reply']
|
end
|
||||||
end
|
if parsed_data['categoryId'].present? && !d.category_id.present?
|
||||||
if parsed_data['categoryId'].present? && !d.category_id.present?
|
d.category_id = parsed_data['categoryId']
|
||||||
d.category_id = parsed_data['categoryId']
|
|
||||||
end
|
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
else
|
|
||||||
raise Discourse::InvalidAccess
|
|
||||||
end
|
end
|
||||||
|
|
||||||
render json: {
|
render json: {
|
||||||
|
Reference in New Issue
Block a user