FrontendController: Return error on installation error.

This commit is contained in:
lain 2020-11-17 16:43:07 +01:00
commit bb9650f3c2
4 changed files with 26 additions and 4 deletions

View file

@ -42,9 +42,11 @@ defmodule Pleroma.Frontend do
else
{:download_or_unzip, _} ->
Logger.info("Could not download or unzip the frontend")
{:error, "Could not download or unzip the frontend"}
_e ->
Logger.info("Could not install the frontend")
{:error, "Could not install the frontend"}
end
end

View file

@ -29,9 +29,9 @@ defmodule Pleroma.Web.AdminAPI.FrontendController do
end
def install(%{body_params: params} = conn, _params) do
Pleroma.Frontend.install(params.name, Map.delete(params, :name))
index(conn, %{})
with :ok <- Pleroma.Frontend.install(params.name, Map.delete(params, :name)) do
index(conn, %{})
end
end
defp installed do

View file

@ -36,7 +36,8 @@ defmodule Pleroma.Web.ApiSpec.Admin.FrontendOperation do
requestBody: request_body("Parameters", install_request(), required: true),
responses: %{
200 => Operation.response("Response", "application/json", list_of_frontends()),
403 => Operation.response("Forbidden", "application/json", ApiError)
403 => Operation.response("Forbidden", "application/json", ApiError),
400 => Operation.response("Error", "application/json", ApiError)
}
}
end