Ensure only indexing public posts and implement clearing and delete
This commit is contained in:
parent
0318e9a599
commit
365024abec
4 changed files with 38 additions and 2 deletions
|
|
@ -1,5 +1,6 @@
|
|||
defmodule Pleroma.Search.Meilisearch do
|
||||
require Logger
|
||||
require Pleroma.Constants
|
||||
|
||||
alias Pleroma.Activity
|
||||
|
||||
|
|
@ -41,7 +42,8 @@ defmodule Pleroma.Search.Meilisearch do
|
|||
def add_to_index(activity) do
|
||||
object = activity.object
|
||||
|
||||
if activity.data["type"] == "Create" and not is_nil(object) and object.data["type"] == "Note" do
|
||||
if activity.data["type"] == "Create" and not is_nil(object) and object.data["type"] == "Note" and
|
||||
Pleroma.Constants.as_public() in object.data["to"] do
|
||||
data = object.data
|
||||
|
||||
endpoint = Pleroma.Config.get([Pleroma.Search.Meilisearch, :url])
|
||||
|
|
@ -57,4 +59,17 @@ defmodule Pleroma.Search.Meilisearch do
|
|||
end
|
||||
end
|
||||
end
|
||||
|
||||
def remove_from_index(object) do
|
||||
endpoint = Pleroma.Config.get([Pleroma.Search.Meilisearch, :url])
|
||||
|
||||
{:ok, _} =
|
||||
Pleroma.HTTP.request(
|
||||
:delete,
|
||||
"#{endpoint}/indexes/objects/documents/#{object.id}",
|
||||
"",
|
||||
[],
|
||||
[]
|
||||
)
|
||||
end
|
||||
end
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue