[#1892] Excluded internal users (applications) from user search results, reinstated...
authorIvan Tashkinov <ivantashkinov@gmail.com>
Fri, 3 Jul 2020 08:02:15 +0000 (11:02 +0300)
committerIvan Tashkinov <ivantashkinov@gmail.com>
Fri, 3 Jul 2020 08:02:15 +0000 (11:02 +0300)
lib/pleroma/user/search.ex
test/user_search_test.exs

index 0293c6ae74070a0d2901a561baa9a358fe7869ce..42ff1de786dd3a9675a2c9871f3905fcdd38719d 100644 (file)
@@ -52,7 +52,7 @@ defmodule Pleroma.User.Search do
     |> base_query(following)
     |> filter_blocked_user(for_user)
     |> filter_invisible_users()
-    |> filter_bots()
+    |> filter_internal_users()
     |> filter_blocked_domains(for_user)
     |> fts_search(query_string)
     |> trigram_rank(query_string)
@@ -110,8 +110,8 @@ defmodule Pleroma.User.Search do
     from(q in query, where: q.invisible == false)
   end
 
-  defp filter_bots(query) do
-    from(q in query, where: q.actor_type not in ["Application", "Service"])
+  defp filter_internal_users(query) do
+    from(q in query, where: q.actor_type != "Application")
   end
 
   defp filter_blocked_user(query, %User{} = blocker) do
index 9a74b9764b20666857d8f0ad0785d50f16b5cf27..f030523d3a9ac178fa7cda4d0df7980f873d160f 100644 (file)
@@ -25,11 +25,13 @@ defmodule Pleroma.UserSearchTest do
       assert found_user.id == user.id
     end
 
-    test "excludes bots from results" do
-      insert(:user, actor_type: "Service", nickname: "bot1")
-      insert(:user, actor_type: "Application", nickname: "bot2")
+    test "excludes service actors from results" do
+      insert(:user, actor_type: "Application", nickname: "user1")
+      service = insert(:user, actor_type: "Service", nickname: "user2")
+      person = insert(:user, actor_type: "Person", nickname: "user3")
 
-      assert [] = User.search("bot")
+      assert [found_user1, found_user2] = User.search("user")
+      assert [found_user1.id, found_user2.id] -- [service.id, person.id] == []
     end
 
     test "accepts limit parameter" do