From: FloatingGhost Date: Thu, 30 Dec 2021 17:47:41 +0000 (+0000) Subject: delete activities X-Git-Url: https://git.squeep.com/?a=commitdiff_plain;h=4e8ee48cffa2a7d1ab3317489042e20a072459da;p=akkoma delete activities --- 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