feat: allow to filter events by local-only

In addition to internal (self + federated) and global (global external search engine), introduce the
self possibility

Closes #1322

Signed-off-by: Thomas Citharel <tcit@tcit.fr>
This commit is contained in:
Thomas Citharel
2024-02-09 10:54:00 +01:00
parent d1b1979ee5
commit 9d99684402
9 changed files with 87 additions and 8 deletions

View File

@@ -56,7 +56,8 @@ defmodule Mobilizon.GraphQL.API.Search do
minimum_visibility: Map.get(args, :minimum_visibility, :public),
current_actor_id: Map.get(args, :current_actor_id),
exclude_my_groups: Map.get(args, :exclude_my_groups, false),
exclude_stale_actors: true
exclude_stale_actors: true,
local_only: Map.get(args, :search_target, :internal) == :self
],
page,
limit
@@ -94,7 +95,13 @@ defmodule Mobilizon.GraphQL.API.Search do
{:ok, service.search_events(Keyword.new(args, fn {k, v} -> {k, v} end))}
else
{:ok, Events.build_events_for_search(Map.put(args, :term, term), page, limit)}
results =
args
|> Map.put(:term, term)
|> Map.put(:local_only, Map.get(args, :search_target, :internal) == :self)
|> Events.build_events_for_search(page, limit)
{:ok, results}
end
end
end

View File

@@ -160,6 +160,8 @@ defmodule Mobilizon.GraphQL.Schema.SearchType do
end
enum :search_target do
value(:self, description: "Search only on content from this instance")
value(:internal,
description: "Search on content from this instance and from the followed instances"
)