AdminAPIController: Refactor.
authorlain <lain@soykaf.club>
Fri, 1 May 2020 12:22:39 +0000 (14:22 +0200)
committerlain <lain@soykaf.club>
Fri, 1 May 2020 12:22:39 +0000 (14:22 +0200)
lib/pleroma/web/admin_api/admin_api_controller.ex
test/web/admin_api/admin_api_controller_test.exs

index 816c11e01f593ff8809811bb0fc461ff56776d9a..c09584fd12f2496ff24d0bc815738d437b4536a2 100644 (file)
@@ -133,18 +133,8 @@ defmodule Pleroma.Web.AdminAPI.AdminAPIController do
 
   action_fallback(:errors)
 
-  def user_delete(%{assigns: %{user: admin}} = conn, %{"nickname" => nickname}) do
-    user = User.get_cached_by_nickname(nickname)
-    User.delete(user)
-
-    ModerationLog.insert_log(%{
-      actor: admin,
-      subject: [user],
-      action: "delete"
-    })
-
-    conn
-    |> json(nickname)
+  def user_delete(conn, %{"nickname" => nickname}) do
+    user_delete(conn, %{"nicknames" => [nickname]})
   end
 
   def user_delete(%{assigns: %{user: admin}} = conn, %{"nicknames" => nicknames}) do
index f80dbf8dd9058d750c81a8eb1a79362130111c68..c92715fabe7f9807102dd17f171fe9241a2a9486 100644 (file)
@@ -156,7 +156,7 @@ defmodule Pleroma.Web.AdminAPI.AdminAPIControllerTest do
       assert ModerationLog.get_log_entry_message(log_entry) ==
                "@#{admin.nickname} deleted users: @#{user.nickname}"
 
-      assert json_response(conn, 200) == user.nickname
+      assert json_response(conn, 200) == [user.nickname]
     end
 
     test "multiple users", %{admin: admin, conn: conn} do