diff --git a/lib/pleroma/elasticsearch/store.ex b/lib/pleroma/elasticsearch/store.ex index 699127c73..db4822aac 100644 --- a/lib/pleroma/elasticsearch/store.ex +++ b/lib/pleroma/elasticsearch/store.ex @@ -14,6 +14,12 @@ defp enabled? do Config.get([:search, :provider]) == Pleroma.Search.Elasticsearch end + def delete_by_id(:activity, id) do + if enabled?() do + Elastix.Document.delete(url(), "activities", "activity", id) + end + end + def put_by_id(:activity, id) do id |> Activity.get_by_id_with_object() diff --git a/lib/pleroma/web/activity_pub/side_effects.ex b/lib/pleroma/web/activity_pub/side_effects.ex index 0460289b7..212588a0b 100644 --- a/lib/pleroma/web/activity_pub/side_effects.ex +++ b/lib/pleroma/web/activity_pub/side_effects.ex @@ -542,6 +542,10 @@ def handle_after_transaction(%Pleroma.Activity{data: %{"type" => "Create"}} = ac Pleroma.Elasticsearch.put_by_id(:activity, activity.id) end + def handle_after_transaction(%Pleroma.Activity{data: %{"type" => "Delete", "deleted_activity_id" => id}}) do + Pleroma.Elasticsearch.delete_by_id(:activity, id) + end + def handle_after_transaction(%Pleroma.Activity{}) do :ok end