projects
/
akkoma
/ blobdiff
commit
grep
author
committer
pickaxe
?
search:
re
summary
|
shortlog
|
log
|
commit
|
commitdiff
|
tree
raw
|
inline
| side by side
Merge pull request 'Small improvements to the Gentoo installation isntructions' ...
[akkoma]
/
lib
/
pleroma
/
user
/
search.ex
diff --git
a/lib/pleroma/user/search.ex
b/lib/pleroma/user/search.ex
index a4f6abca24b358a0764977de3152f5a40a2868a4..ddce51775bd2dd74cb454f49ddbea6eab8f14111 100644
(file)
--- a/
lib/pleroma/user/search.ex
+++ b/
lib/pleroma/user/search.ex
@@
-62,6
+62,11
@@
defmodule Pleroma.User.Search do
end
end
end
end
+ def sanitise_domain(domain) do
+ domain
+ |> String.replace(~r/[!-\,|@|?|<|>|[-`|{-~|\/|:|\s]+/, "")
+ end
+
defp format_query(query_string) do
# Strip the beginning @ off if there is a query
query_string = String.trim_leading(query_string, "@")
defp format_query(query_string) do
# Strip the beginning @ off if there is a query
query_string = String.trim_leading(query_string, "@")
@@
-69,7
+74,7
@@
defmodule Pleroma.User.Search do
with [name, domain] <- String.split(query_string, "@") do
encoded_domain =
domain
with [name, domain] <- String.split(query_string, "@") do
encoded_domain =
domain
- |>
String.replace(~r/[!-\-|@|[-`|{-~|\/|:|\s]+/, ""
)
+ |>
sanitise_domain(
)
|> String.to_charlist()
|> :idna.encode()
|> to_string()
|> String.to_charlist()
|> :idna.encode()
|> to_string()
@@
-94,6
+99,7
@@
defmodule Pleroma.User.Search do
|> subquery()
|> order_by(desc: :search_rank)
|> maybe_restrict_local(for_user)
|> subquery()
|> order_by(desc: :search_rank)
|> maybe_restrict_local(for_user)
+ |> filter_deactivated_users()
end
defp select_top_users(query, top_user_ids) do
end
defp select_top_users(query, top_user_ids) do
@@
-166,6
+172,10
@@
defmodule Pleroma.User.Search do
from(q in query, where: q.actor_type != "Application")
end
from(q in query, where: q.actor_type != "Application")
end
+ defp filter_deactivated_users(query) do
+ from(q in query, where: q.is_active == true)
+ end
+
defp filter_blocked_user(query, %User{} = blocker) do
query
|> join(:left, [u], b in Pleroma.UserRelationship,
defp filter_blocked_user(query, %User{} = blocker) do
query
|> join(:left, [u], b in Pleroma.UserRelationship,