Change validation error status codes to be more appropriate
This commit is contained in:
parent
ee68244141
commit
0407ffe75f
@ -488,12 +488,12 @@ defmodule Pleroma.Web.MastodonAPI.MastodonAPIController do
|
|||||||
case get_cached_status_or_post(conn, params) do
|
case get_cached_status_or_post(conn, params) do
|
||||||
{:ignore, message} ->
|
{:ignore, message} ->
|
||||||
conn
|
conn
|
||||||
|> put_status(401)
|
|> put_status(422)
|
||||||
|> json(%{error: message})
|
|> json(%{error: message})
|
||||||
|
|
||||||
{:error, message} ->
|
{:error, message} ->
|
||||||
conn
|
conn
|
||||||
|> put_status(401)
|
|> put_status(422)
|
||||||
|> json(%{error: message})
|
|> json(%{error: message})
|
||||||
|
|
||||||
{_, activity} ->
|
{_, activity} ->
|
||||||
|
@ -181,7 +181,7 @@ defmodule Pleroma.Web.MastodonAPI.MastodonAPIControllerTest do
|
|||||||
"poll" => %{"options" => Enum.map(0..limit, fn _ -> "desu" end), "expires_in" => 1}
|
"poll" => %{"options" => Enum.map(0..limit, fn _ -> "desu" end), "expires_in" => 1}
|
||||||
})
|
})
|
||||||
|
|
||||||
%{"error" => error} = json_response(conn, 401)
|
%{"error" => error} = json_response(conn, 422)
|
||||||
assert error == "Poll can't contain more than #{limit} options"
|
assert error == "Poll can't contain more than #{limit} options"
|
||||||
end
|
end
|
||||||
|
|
||||||
@ -200,7 +200,7 @@ defmodule Pleroma.Web.MastodonAPI.MastodonAPIControllerTest do
|
|||||||
}
|
}
|
||||||
})
|
})
|
||||||
|
|
||||||
%{"error" => error} = json_response(conn, 401)
|
%{"error" => error} = json_response(conn, 422)
|
||||||
assert error == "Poll options cannot be longer than #{limit} characters each"
|
assert error == "Poll options cannot be longer than #{limit} characters each"
|
||||||
end
|
end
|
||||||
|
|
||||||
@ -219,7 +219,7 @@ defmodule Pleroma.Web.MastodonAPI.MastodonAPIControllerTest do
|
|||||||
}
|
}
|
||||||
})
|
})
|
||||||
|
|
||||||
%{"error" => error} = json_response(conn, 401)
|
%{"error" => error} = json_response(conn, 422)
|
||||||
assert error == "Expiration date is too soon"
|
assert error == "Expiration date is too soon"
|
||||||
end
|
end
|
||||||
|
|
||||||
@ -238,7 +238,7 @@ defmodule Pleroma.Web.MastodonAPI.MastodonAPIControllerTest do
|
|||||||
}
|
}
|
||||||
})
|
})
|
||||||
|
|
||||||
%{"error" => error} = json_response(conn, 401)
|
%{"error" => error} = json_response(conn, 422)
|
||||||
assert error == "Expiration date is too far in the future"
|
assert error == "Expiration date is too far in the future"
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
Loading…
Reference in New Issue
Block a user