Apply suggestion to lib/pleroma/web/admin_api/controllers/admin_api_controller.ex

This commit is contained in:
Alexander Strizhakov 2020-05-27 10:55:42 +00:00
parent 3249141588
commit 047a11c48f

View file

@ -715,11 +715,7 @@ defmodule Pleroma.Web.AdminAPI.AdminAPIController do
json(conn, %{status: "success"}) json(conn, %{status: "success"})
else else
{:error, changeset} -> {:error, changeset} ->
errors = errors = Map.new(changeset.errors, fn {key, {error, _}} -> {key, error} end)
Enum.reduce(changeset.errors, %{}, fn
{key, {error, _}}, acc ->
Map.put(acc, key, error)
end)
json(conn, %{errors: errors}) json(conn, %{errors: errors})