Polish IdempotencyPlug
This commit is contained in:
parent
159630b21c
commit
889a9c3a3f
3 changed files with 14 additions and 14 deletions
|
|
@ -29,16 +29,16 @@ defmodule Pleroma.Plugs.IdempotencyPlug do
|
|||
{:ok, nil} ->
|
||||
cache_resposnse(conn, key)
|
||||
|
||||
{atom, message} when atom in [:ignore, :error] ->
|
||||
render_error(conn, message)
|
||||
|
||||
{:ok, record} ->
|
||||
send_cached(conn, key, record)
|
||||
|
||||
{atom, message} when atom in [:ignore, :error] ->
|
||||
render_error(conn, message)
|
||||
end
|
||||
end
|
||||
|
||||
defp cache_resposnse(conn, key) do
|
||||
Plug.Conn.register_before_send(conn, fn conn ->
|
||||
register_before_send(conn, fn conn ->
|
||||
[request_id] = get_resp_header(conn, "x-request-id")
|
||||
content_type = get_content_type(conn)
|
||||
|
||||
|
|
|
|||
|
|
@ -564,7 +564,7 @@ defmodule Pleroma.Web.MastodonAPI.MastodonAPIController do
|
|||
case CommonAPI.post(user, params) do
|
||||
{:error, message} ->
|
||||
conn
|
||||
|> put_status(422)
|
||||
|> put_status(:unprocessable_entity)
|
||||
|> json(%{error: message})
|
||||
|
||||
{:ok, activity} ->
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue