diff options
author | Tusooa Zhu <tusooa@kazv.moe> | 2022-05-05 10:44:34 -0400 |
---|---|---|
committer | Tusooa Zhu <tusooa@kazv.moe> | 2022-05-06 13:54:13 -0400 |
commit | 826deb737588c75d9431d260eea826208100385c (patch) | |
tree | 54838d9e48c5c554bfa987c3a0a28578ef960d37 /lib | |
parent | 38af42968d7731ca4923a5130244638749f43ee3 (diff) | |
download | pleroma-826deb737588c75d9431d260eea826208100385c.tar.gz pleroma-826deb737588c75d9431d260eea826208100385c.zip |
Make local-only statuses searchable
Ref: fix-local-public
Diffstat (limited to 'lib')
-rw-r--r-- | lib/pleroma/activity/search.ex | 13 |
1 files changed, 11 insertions, 2 deletions
diff --git a/lib/pleroma/activity/search.ex b/lib/pleroma/activity/search.ex index 694dc5709..b56d4a5aa 100644 --- a/lib/pleroma/activity/search.ex +++ b/lib/pleroma/activity/search.ex @@ -30,7 +30,7 @@ defmodule Pleroma.Activity.Search do Activity |> Activity.with_preloaded_object() |> Activity.restrict_deactivated_users() - |> restrict_public() + |> restrict_public(user) |> query_with(index_type, search_query, search_function) |> maybe_restrict_local(user) |> maybe_restrict_author(author) @@ -57,7 +57,16 @@ defmodule Pleroma.Activity.Search do def maybe_restrict_blocked(query, _), do: query - defp restrict_public(q) do + defp restrict_public(q, user) when not is_nil(user) do + intended_recipients = [Pleroma.Constants.as_public(), Pleroma.Web.ActivityPub.Utils.as_local_public()] + + from([a, o] in q, + where: fragment("?->>'type' = 'Create'", a.data), + where: fragment("? && ?", ^intended_recipients, a.recipients) + ) + end + + defp restrict_public(q, _user) do from([a, o] in q, where: fragment("?->>'type' = 'Create'", a.data), where: ^Pleroma.Constants.as_public() in a.recipients |