[#2301] Quick fix: users with is_discoverable == false (default!) are included in search results.

This commit is contained in:
Ivan Tashkinov 2020-11-19 18:08:22 +03:00
parent 6f9b03384f
commit fcad3e716a
2 changed files with 8 additions and 5 deletions

View file

@ -85,7 +85,7 @@ defmodule Pleroma.User.Search do
|> base_query(following) |> base_query(following)
|> filter_blocked_user(for_user) |> filter_blocked_user(for_user)
|> filter_invisible_users() |> filter_invisible_users()
|> filter_discoverable_users() |> filter_non_discoverable_users()
|> filter_internal_users() |> filter_internal_users()
|> filter_blocked_domains(for_user) |> filter_blocked_domains(for_user)
|> fts_search(query_string) |> fts_search(query_string)
@ -163,8 +163,10 @@ defmodule Pleroma.User.Search do
from(q in query, where: q.invisible == false) from(q in query, where: q.invisible == false)
end end
defp filter_discoverable_users(query) do defp filter_non_discoverable_users(query) do
from(q in query, where: q.is_discoverable == true) # Note: commented out — can't do it with users being non-discoverable by default
# from(q in query, where: q.is_discoverable == true)
query
end end
defp filter_internal_users(query) do defp filter_internal_users(query) do

View file

@ -65,12 +65,13 @@ defmodule Pleroma.UserSearchTest do
assert found_user.id == user.id assert found_user.id == user.id
end end
test "excludes users when discoverable is false" do # NOTE: as long as users are non-discoverable by default, we can't filter out most users: #2301
test "does NOT exclude non-discoverable users from results (as long as it's the default)" do
insert(:user, %{nickname: "john 3000", is_discoverable: false}) insert(:user, %{nickname: "john 3000", is_discoverable: false})
insert(:user, %{nickname: "john 3001"}) insert(:user, %{nickname: "john 3001"})
users = User.search("john") users = User.search("john")
assert Enum.count(users) == 1 assert Enum.count(users) == 2
end end
test "excludes service actors from results" do test "excludes service actors from results" do