summaryrefslogtreecommitdiff
path: root/lib
diff options
context:
space:
mode:
authorEkaterina Vaartis <vaartis@kotobank.ch>2022-08-27 00:19:08 +0300
committerEkaterina Vaartis <vaartis@kotobank.ch>2022-10-10 20:19:09 +0300
commit102ebb42bdba1673da39a8fa8ed1662bc8565aa4 (patch)
tree00026b84870e374f5593add93c991dee9ec5cf34 /lib
parent119b2b847b76c7300bd71699d9f2e5676bdb0bb4 (diff)
downloadpleroma-102ebb42bdba1673da39a8fa8ed1662bc8565aa4.tar.gz
pleroma-102ebb42bdba1673da39a8fa8ed1662bc8565aa4.zip
Make search a callback
Diffstat (limited to 'lib')
-rw-r--r--lib/pleroma/search/database_search.ex1
-rw-r--r--lib/pleroma/search/meilisearch.ex1
-rw-r--r--lib/pleroma/search/search_backend.ex11
3 files changed, 11 insertions, 2 deletions
diff --git a/lib/pleroma/search/database_search.ex b/lib/pleroma/search/database_search.ex
index 3735a5fab..9a340abf1 100644
--- a/lib/pleroma/search/database_search.ex
+++ b/lib/pleroma/search/database_search.ex
@@ -15,6 +15,7 @@ defmodule Pleroma.Search.DatabaseSearch do
@behaviour Pleroma.Search.SearchBackend
+ @impl true
def search(user, search_query, options \\ []) do
index_type = if Pleroma.Config.get([:database, :rum_enabled]), do: :rum, else: :gin
limit = Enum.min([Keyword.get(options, :limit), 40])
diff --git a/lib/pleroma/search/meilisearch.ex b/lib/pleroma/search/meilisearch.ex
index 2e13b8407..4e88169d2 100644
--- a/lib/pleroma/search/meilisearch.ex
+++ b/lib/pleroma/search/meilisearch.ex
@@ -75,6 +75,7 @@ defmodule Pleroma.Search.Meilisearch do
)
end
+ @impl true
def search(user, query, options \\ []) do
limit = Enum.min([Keyword.get(options, :limit), 40])
offset = Keyword.get(options, :offset, 0)
diff --git a/lib/pleroma/search/search_backend.ex b/lib/pleroma/search/search_backend.ex
index ed6bfd329..a42e2f5f6 100644
--- a/lib/pleroma/search/search_backend.ex
+++ b/lib/pleroma/search/search_backend.ex
@@ -1,10 +1,17 @@
defmodule Pleroma.Search.SearchBackend do
@doc """
+ Search statuses with a query, restricting to only those the user should have access to.
+ """
+ @callback search(user :: Pleroma.User.t(), query :: String.t(), options :: [any()]) :: [
+ Pleroma.Activity.t()
+ ]
+
+ @doc """
Add the object associated with the activity to the search index.
The whole activity is passed, to allow filtering on things such as scope.
"""
- @callback add_to_index(activity :: Pleroma.Activity.t()) :: nil
+ @callback add_to_index(activity :: Pleroma.Activity.t()) :: :ok | {:error, any()}
@doc """
Remove the object from the index.
@@ -13,5 +20,5 @@ defmodule Pleroma.Search.SearchBackend do
is what contains the actual content and there is no need for fitlering when removing
from index.
"""
- @callback remove_from_index(object :: Pleroma.Object.t()) :: nil
+ @callback remove_from_index(object :: Pleroma.Object.t()) :: {:ok, any()} | {:error, any()}
end