delete activities
authorFloatingGhost <hannah@coffee-and-dreams.uk>
Thu, 30 Dec 2021 17:47:41 +0000 (17:47 +0000)
committerFloatingGhost <hannah@coffee-and-dreams.uk>
Thu, 30 Dec 2021 18:05:44 +0000 (18:05 +0000)
lib/pleroma/elasticsearch/store.ex
lib/pleroma/web/activity_pub/side_effects.ex

index 699127c73cca91477b02b9ce62da00c085afe15a..db4822aacb63157312041d87d3bae9bcfd263240 100644 (file)
@@ -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()
index 0460289b77c63152dbd9f6bd16ff14ae5a4274c3..212588a0bc3743d5de692c3ac42173d952ecd6ea 100644 (file)
@@ -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