summaryrefslogtreecommitdiff
path: root/lib
diff options
context:
space:
mode:
authorLain Soykaf <lain@lain.com>2024-05-23 14:38:30 +0400
committerLain Soykaf <lain@lain.com>2024-05-23 14:38:30 +0400
commit94e4f215896dc7976a54fd146daf3e286602925a (patch)
tree34cdc2812b09154ddecebe910ab6b9880aba15f0 /lib
parentf726e5fbbdab89dd2a8cb498112ed6866047d3d1 (diff)
downloadpleroma-94e4f215896dc7976a54fd146daf3e286602925a.tar.gz
pleroma-94e4f215896dc7976a54fd146daf3e286602925a.zip
QdrantSearch: Deal with actor restrictions
Diffstat (limited to 'lib')
-rw-r--r--lib/pleroma/search/qdrant_search.ex22
1 files changed, 20 insertions, 2 deletions
diff --git a/lib/pleroma/search/qdrant_search.ex b/lib/pleroma/search/qdrant_search.ex
index 283c43075..9cb34ef71 100644
--- a/lib/pleroma/search/qdrant_search.ex
+++ b/lib/pleroma/search/qdrant_search.ex
@@ -43,23 +43,41 @@ defmodule Pleroma.Search.QdrantSearch do
end
end
+ defp actor_from_activity(%{data: %{"actor" => actor}}) do
+ actor
+ end
+
+ defp actor_from_activity(_), do: nil
+
defp build_index_payload(activity, embedding) do
+ actor = actor_from_activity(activity)
+ published_at = activity.data["published"]
+
%{
points: [
%{
id: activity.id |> FlakeId.from_string() |> Ecto.UUID.cast!(),
- vector: embedding
+ vector: embedding,
+ payload: %{actor: actor, published_at: published_at}
}
]
}
end
defp build_search_payload(embedding, options) do
- %{
+ base = %{
vector: embedding,
limit: options[:limit] || 20,
offset: options[:offset] || 0
}
+
+ if options[:actor] do
+ Map.put(base, :filter, %{
+ must: [%{key: "actor", match: %{value: options[:actor].ap_id}}]
+ })
+ else
+ base
+ end
end
@impl true