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 35a828008ceb34e6b6653b34d47df68b65c54d53..ddce51775bd2dd74cb454f49ddbea6eab8f14111 100644
(file)
--- a/
lib/pleroma/user/search.ex
+++ b/
lib/pleroma/user/search.ex
@@
-1,5
+1,5
@@
# Pleroma: A lightweight social networking server
# Pleroma: A lightweight social networking server
-# Copyright © 2017-202
0
Pleroma Authors <https://pleroma.social/>
+# Copyright © 2017-202
1
Pleroma Authors <https://pleroma.social/>
# SPDX-License-Identifier: AGPL-3.0-only
defmodule Pleroma.User.Search do
# SPDX-License-Identifier: AGPL-3.0-only
defmodule Pleroma.User.Search do
@@
-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()
@@
-85,7
+90,6
@@
defmodule Pleroma.User.Search do
|> base_query(following)
|> filter_blocked_user(for_user)
|> filter_invisible_users()
|> base_query(following)
|> filter_blocked_user(for_user)
|> filter_invisible_users()
- |> filter_discoverable_users()
|> filter_internal_users()
|> filter_blocked_domains(for_user)
|> fts_search(query_string)
|> filter_internal_users()
|> filter_blocked_domains(for_user)
|> fts_search(query_string)
@@
-95,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
@@
-163,14
+168,14
@@
defmodule Pleroma.User.Search do
from(q in query, where: q.invisible == false)
end
from(q in query, where: q.invisible == false)
end
- defp filter_discoverable_users(query) do
- from(q in query, where: q.discoverable == true)
- end
-
defp filter_internal_users(query) do
from(q in query, where: q.actor_type != "Application")
end
defp filter_internal_users(query) do
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,