X-Git-Url: https://git.squeep.com/?a=blobdiff_plain;f=lib%2Fpleroma%2Fuser%2Fsearch.ex;h=cec59c372b835f76c2b54f0e68e814e6282c7366;hb=b02df1803e16b40ad8a30465604e2892b6d65e6f;hp=2b3c7b5b4f08129b36a6dfe7984c3e511b6db94b;hpb=4f88b1b4353c1216273e462fb687e8b43b257e37;p=akkoma
diff --git a/lib/pleroma/user/search.ex b/lib/pleroma/user/search.ex
index 2b3c7b5b4..cec59c372 100644
--- a/lib/pleroma/user/search.ex
+++ b/lib/pleroma/user/search.ex
@@ -1,5 +1,5 @@
# Pleroma: A lightweight social networking server
-# Copyright © 2017-2019 Pleroma Authors
+# Copyright © 2017-2020 Pleroma Authors
# SPDX-License-Identifier: AGPL-3.0-only
defmodule Pleroma.User.Search do
@@ -33,9 +33,15 @@ defmodule Pleroma.User.Search do
# Strip the beginning @ off if there is a query
query_string = String.trim_leading(query_string, "@")
- with [name, domain] <- String.split(query_string, "@"),
- formatted_domain <- String.replace(domain, ~r/[!-\-|@|[-`|{-~|\/|:|\s]+/, "") do
- name <> "@" <> to_string(:idna.encode(formatted_domain))
+ with [name, domain] <- String.split(query_string, "@") do
+ encoded_domain =
+ domain
+ |> String.replace(~r/[!-\-|@|[-`|{-~|\/|:|\s]+/, "")
+ |> String.to_charlist()
+ |> :idna.encode()
+ |> to_string()
+
+ name <> "@" <> encoded_domain
else
_ -> query_string
end
@@ -45,6 +51,7 @@ defmodule Pleroma.User.Search do
for_user
|> base_query(following)
|> filter_blocked_user(for_user)
+ |> filter_invisible_users()
|> filter_blocked_domains(for_user)
|> fts_search(query_string)
|> trigram_rank(query_string)
@@ -98,6 +105,10 @@ defmodule Pleroma.User.Search do
defp base_query(_user, false), do: User
defp base_query(user, true), do: User.get_followers_query(user)
+ defp filter_invisible_users(query) do
+ from(q in query, where: q.invisible == false)
+ end
+
defp filter_blocked_user(query, %User{} = blocker) do
query
|> join(:left, [u], b in Pleroma.UserRelationship,