projects
/
akkoma
/ blobdiff
commit
grep
author
committer
pickaxe
?
search:
re
summary
|
shortlog
|
log
|
commit
|
commitdiff
|
tree
raw
|
inline
| side by side
Merge branch 'develop' into feature/matstodon-statuses-by-name
[akkoma]
/
lib
/
pleroma
/
web
/
admin_api
/
admin_api_controller.ex
diff --git
a/lib/pleroma/web/admin_api/admin_api_controller.ex
b/lib/pleroma/web/admin_api/admin_api_controller.ex
index 0a2482a8c85c45224d8d2916f503f8778ed4c381..4a0bf482346782a5bd25010efe5b18bfb2edc949 100644
(file)
--- a/
lib/pleroma/web/admin_api/admin_api_controller.ex
+++ b/
lib/pleroma/web/admin_api/admin_api_controller.ex
@@
-160,9
+160,7
@@
defmodule Pleroma.Web.AdminAPI.AdminAPIController do
end
def right_add(conn, _) do
end
def right_add(conn, _) do
- conn
- |> put_status(404)
- |> json(%{error: "No such permission_group"})
+ render_error(conn, :not_found, "No such permission_group")
end
def right_get(conn, %{"nickname" => nickname}) do
end
def right_get(conn, %{"nickname" => nickname}) do
@@
-184,9
+182,7
@@
defmodule Pleroma.Web.AdminAPI.AdminAPIController do
)
when permission_group in ["moderator", "admin"] do
if admin_nickname == nickname do
)
when permission_group in ["moderator", "admin"] do
if admin_nickname == nickname do
- conn
- |> put_status(403)
- |> json(%{error: "You can't revoke your own admin status."})
+ render_error(conn, :forbidden, "You can't revoke your own admin status.")
else
user = User.get_cached_by_nickname(nickname)
else
user = User.get_cached_by_nickname(nickname)
@@
-207,9
+203,7
@@
defmodule Pleroma.Web.AdminAPI.AdminAPIController do
end
def right_delete(conn, _) do
end
def right_delete(conn, _) do
- conn
- |> put_status(404)
- |> json(%{error: "No such permission_group"})
+ render_error(conn, :not_found, "No such permission_group")
end
def set_activation_status(conn, %{"nickname" => nickname, "status" => status}) do
end
def set_activation_status(conn, %{"nickname" => nickname, "status" => status}) do
@@
-377,13
+371,13
@@
defmodule Pleroma.Web.AdminAPI.AdminAPIController do
if Pleroma.Config.get([:instance, :dynamic_configuration]) do
updated =
Enum.map(configs, fn
if Pleroma.Config.get([:instance, :dynamic_configuration]) do
updated =
Enum.map(configs, fn
- %{"group" => group, "key" => key, "value" => value} ->
- {:ok, config} = Config.update_or_create(%{group: group, key: key, value: value})
- config
-
%{"group" => group, "key" => key, "delete" => "true"} ->
{:ok, _} = Config.delete(%{group: group, key: key})
nil
%{"group" => group, "key" => key, "delete" => "true"} ->
{:ok, _} = Config.delete(%{group: group, key: key})
nil
+
+ %{"group" => group, "key" => key, "value" => value} ->
+ {:ok, config} = Config.update_or_create(%{group: group, key: key, value: value})
+ config
end)
|> Enum.reject(&is_nil(&1))
end)
|> Enum.reject(&is_nil(&1))
@@
-401,26
+395,26
@@
defmodule Pleroma.Web.AdminAPI.AdminAPIController do
def errors(conn, {:error, :not_found}) do
conn
def errors(conn, {:error, :not_found}) do
conn
- |> put_status(
404
)
- |> json(
"Not found"
)
+ |> put_status(
:not_found
)
+ |> json(
dgettext("errors", "Not found")
)
end
def errors(conn, {:error, reason}) do
conn
end
def errors(conn, {:error, reason}) do
conn
- |> put_status(
400
)
+ |> put_status(
:bad_request
)
|> json(reason)
end
def errors(conn, {:param_cast, _}) do
conn
|> json(reason)
end
def errors(conn, {:param_cast, _}) do
conn
- |> put_status(
400
)
- |> json(
"Invalid parameters"
)
+ |> put_status(
:bad_request
)
+ |> json(
dgettext("errors", "Invalid parameters")
)
end
def errors(conn, _) do
conn
end
def errors(conn, _) do
conn
- |> put_status(
500
)
- |> json(
"Something went wrong"
)
+ |> put_status(
:internal_server_error
)
+ |> json(
dgettext("errors", "Something went wrong")
)
end
defp page_params(params) do
end
defp page_params(params) do