Return 400 when update request is invalid

This commit is contained in:
2024-02-24 16:07:45 +11:00
parent 8418c5f003
commit 45221e653d
2 changed files with 4 additions and 0 deletions

View File

@@ -26,6 +26,8 @@ module Micropub
res.status = 200 res.status = 200
in Failure[:not_permitted] in Failure[:not_permitted]
halt 401 halt 401
in Failure[:invalid_request]
halt 400
end end
end end

View File

@@ -13,6 +13,8 @@ module Micropub
post = post_repo.fetch!(slug) post = post_repo.fetch!(slug)
if params.key? :replace if params.key? :replace
return Failure(:invalid_request) 400 unless params[:replace].is_a?(Hash)
content = params[:replace].delete(:content) content = params[:replace].delete(:content)
content = content.is_a?(Array) ? content.first : content content = content.is_a?(Array) ? content.first : content
name = params[:replace].delete(:name) name = params[:replace].delete(:name)