Show current user in users list as well
authorMaxim Filippov <colixer@gmail.com>
Fri, 1 Mar 2019 17:23:03 +0000 (20:23 +0300)
committerMaxim Filippov <colixer@gmail.com>
Fri, 1 Mar 2019 17:23:03 +0000 (20:23 +0300)
lib/pleroma/user.ex
lib/pleroma/web/admin_api/admin_api_controller.ex
test/web/admin_api/admin_api_controller_test.exs

index af3ce705d9c307d0a7661bc20b9c66c5415e310b..37f8da8922f800cd014eafd58b14c770407d620d 100644 (file)
@@ -779,10 +779,9 @@ defmodule Pleroma.User do
     Enum.uniq_by(fts_results ++ trigram_results, & &1.id)
   end
 
-  def all_except_one(user, page, page_size) do
+  def all(page, page_size) do
     from(
       u in User,
-      where: u.id != ^user.id,
       limit: ^page_size,
       offset: ^((page - 1) * page_size),
       order_by: u.id
index a8f9e5012a652adbf18ef112b4ab669ed16fd023..270097d3564a504070a87d3d1aadff6abb3105d3 100644 (file)
@@ -65,7 +65,7 @@ defmodule Pleroma.Web.AdminAPI.AdminAPIController do
 
   def list_users(%{assigns: %{user: admin}} = conn, %{"page" => page_string}) do
     with {page, _} <- Integer.parse(page_string),
-         users <- User.all_except_one(admin, page, @users_page_size),
+         users <- User.all(page, @users_page_size),
          count <- User.count_all_except_one(admin),
          do:
            conn
index 460f2a6bd3d89e4393d14a9cb8c94d7d1ca9721c..0679f5dfeb290f3f4cbf007bd1c84909feae9f36 100644 (file)
@@ -345,6 +345,11 @@ defmodule Pleroma.Web.AdminAPI.AdminAPIControllerTest do
                "count" => 1,
                "page_size" => 50,
                "users" => [
+                %{
+                  "deactivated" => admin.info.deactivated,
+                  "id" => admin.id,
+                  "nickname" => admin.nickname
+                },
                  %{
                    "deactivated" => user.info.deactivated,
                    "id" => user.id,
@@ -399,16 +404,16 @@ defmodule Pleroma.Web.AdminAPI.AdminAPIControllerTest do
         |> get("/api/pleroma/admin/users/search?query=bo")
 
       assert json_response(conn, 200) == %{
-              "count" => 1,
-              "page_size" => 50,
-              "users" => [
-                %{
-                  "deactivated" => user.info.deactivated,
-                  "id" => user.id,
-                  "nickname" => user.nickname
-                }
-              ]
-            }
+               "count" => 1,
+               "page_size" => 50,
+               "users" => [
+                 %{
+                   "deactivated" => user.info.deactivated,
+                   "id" => user.id,
+                   "nickname" => user.nickname
+                 }
+               ]
+             }
     end
 
     test "only local users" do
@@ -423,16 +428,16 @@ defmodule Pleroma.Web.AdminAPI.AdminAPIControllerTest do
         |> get("/api/pleroma/admin/users/search?query=bo&local=true")
 
       assert json_response(conn, 200) == %{
-              "count" => 1,
-              "page_size" => 50,
-              "users" => [
-                %{
-                  "deactivated" => user.info.deactivated,
-                  "id" => user.id,
-                  "nickname" => user.nickname
-                }
-              ]
-            }
+               "count" => 1,
+               "page_size" => 50,
+               "users" => [
+                 %{
+                   "deactivated" => user.info.deactivated,
+                   "id" => user.id,
+                   "nickname" => user.nickname
+                 }
+               ]
+             }
     end
   end
 end