forked from AkkomaGang/akkoma
[#1892] Excluded internal users (applications) from user search results, reinstated service actors in search results.
This commit is contained in:
parent
3d2989278c
commit
90764670dc
2 changed files with 9 additions and 7 deletions
|
@ -52,7 +52,7 @@ defp search_query(query_string, for_user, following) do
|
||||||
|> base_query(following)
|
|> base_query(following)
|
||||||
|> filter_blocked_user(for_user)
|
|> filter_blocked_user(for_user)
|
||||||
|> filter_invisible_users()
|
|> filter_invisible_users()
|
||||||
|> filter_bots()
|
|> filter_internal_users()
|
||||||
|> filter_blocked_domains(for_user)
|
|> filter_blocked_domains(for_user)
|
||||||
|> fts_search(query_string)
|
|> fts_search(query_string)
|
||||||
|> trigram_rank(query_string)
|
|> trigram_rank(query_string)
|
||||||
|
@ -110,8 +110,8 @@ defp filter_invisible_users(query) do
|
||||||
from(q in query, where: q.invisible == false)
|
from(q in query, where: q.invisible == false)
|
||||||
end
|
end
|
||||||
|
|
||||||
defp filter_bots(query) do
|
defp filter_internal_users(query) do
|
||||||
from(q in query, where: q.actor_type not in ["Application", "Service"])
|
from(q in query, where: q.actor_type != "Application")
|
||||||
end
|
end
|
||||||
|
|
||||||
defp filter_blocked_user(query, %User{} = blocker) do
|
defp filter_blocked_user(query, %User{} = blocker) do
|
||||||
|
|
|
@ -25,11 +25,13 @@ test "excludes invisible users from results" do
|
||||||
assert found_user.id == user.id
|
assert found_user.id == user.id
|
||||||
end
|
end
|
||||||
|
|
||||||
test "excludes bots from results" do
|
test "excludes service actors from results" do
|
||||||
insert(:user, actor_type: "Service", nickname: "bot1")
|
insert(:user, actor_type: "Application", nickname: "user1")
|
||||||
insert(:user, actor_type: "Application", nickname: "bot2")
|
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
|
end
|
||||||
|
|
||||||
test "accepts limit parameter" do
|
test "accepts limit parameter" do
|
||||||
|
|
Loading…
Reference in a new issue