From 4e8ee48cffa2a7d1ab3317489042e20a072459da Mon Sep 17 00:00:00 2001 From: FloatingGhost Date: Thu, 30 Dec 2021 17:47:41 +0000 Subject: [PATCH] delete activities --- lib/pleroma/elasticsearch/store.ex | 6 ++++++ lib/pleroma/web/activity_pub/side_effects.ex | 4 ++++ 2 files changed, 10 insertions(+) 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 @@ defmodule Pleroma.Elasticsearch 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 @@ defmodule Pleroma.Web.ActivityPub.SideEffects do 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