2021-11-16 11:54:26 -07:00
|
|
|
defmodule Pleroma.Search.DatabaseSearch do
|
2021-11-14 10:24:05 -07:00
|
|
|
def add_to_index(activity) do
|
|
|
|
search_module = Pleroma.Config.get([Pleroma.Search, :module])
|
2021-12-12 10:23:44 -07:00
|
|
|
|
2021-11-14 10:24:05 -07:00
|
|
|
ConcurrentLimiter.limit(Pleroma.Search, fn ->
|
|
|
|
Task.start(fn -> search_module.add_to_index(activity) end)
|
|
|
|
end)
|
|
|
|
end
|
|
|
|
|
|
|
|
def remove_from_index(object) do
|
|
|
|
# Also delete from search index
|
|
|
|
search_module = Pleroma.Config.get([Pleroma.Search, :module])
|
|
|
|
|
|
|
|
ConcurrentLimiter.limit(Pleroma.Search, fn ->
|
|
|
|
Task.start(fn -> search_module.remove_from_index(object) end)
|
|
|
|
end)
|
|
|
|
end
|
2021-11-16 11:54:26 -07:00
|
|
|
|
|
|
|
def search(query, options) do
|
|
|
|
search_module = Pleroma.Config.get([Pleroma.Search, :module], Pleroma.Activity)
|
|
|
|
|
|
|
|
search_module.search(options[:for_user], query, options)
|
|
|
|
end
|
2021-12-12 10:23:44 -07:00
|
|
|
end
|