2022-01-22 12:23:11 +00:00
|
|
|
defmodule Pleroma.Workers.SearchIndexingWorker do
|
|
|
|
use Pleroma.Workers.WorkerHelper, queue: "search_indexing"
|
|
|
|
|
|
|
|
@impl Oban.Worker
|
|
|
|
|
2023-11-12 10:49:50 +00:00
|
|
|
alias Pleroma.Config.Getting, as: Config
|
|
|
|
|
2022-01-22 12:23:11 +00:00
|
|
|
def perform(%Job{args: %{"op" => "add_to_index", "activity" => activity_id}}) do
|
|
|
|
activity = Pleroma.Activity.get_by_id_with_object(activity_id)
|
|
|
|
|
2023-11-12 10:49:50 +00:00
|
|
|
search_module = Config.get([Pleroma.Search, :module])
|
2022-01-22 12:23:11 +00:00
|
|
|
|
|
|
|
search_module.add_to_index(activity)
|
|
|
|
end
|
|
|
|
|
|
|
|
def perform(%Job{args: %{"op" => "remove_from_index", "object" => object_id}}) do
|
|
|
|
object = Pleroma.Object.get_by_id(object_id)
|
|
|
|
|
2023-11-12 10:49:50 +00:00
|
|
|
search_module = Config.get([Pleroma.Search, :module])
|
2022-01-22 12:23:11 +00:00
|
|
|
|
|
|
|
search_module.remove_from_index(object)
|
|
|
|
end
|
|
|
|
end
|