summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorEgor Kislitsyn <egor@kislitsyn.com>2020-03-24 17:38:18 +0400
committerEgor Kislitsyn <egor@kislitsyn.com>2020-03-24 17:38:18 +0400
commitd1a9716a988fe9f670033ad46cc9637038fbd1e8 (patch)
treee6edf8271a777d9d5c321648de80fae1cb652a8d
parentfbf02a372254940c16908ef608e67fd28cfa4bf0 (diff)
Fix activity deletion
-rw-r--r--lib/pleroma/web/activity_pub/activity_pub.ex10
-rw-r--r--test/web/activity_pub/activity_pub_test.exs6
2 files changed, 16 insertions, 0 deletions
diff --git a/lib/pleroma/web/activity_pub/activity_pub.ex b/lib/pleroma/web/activity_pub/activity_pub.ex
index 30e282840..974231925 100644
--- a/lib/pleroma/web/activity_pub/activity_pub.ex
+++ b/lib/pleroma/web/activity_pub/activity_pub.ex
@@ -583,6 +583,16 @@ defmodule Pleroma.Web.ActivityPub.ActivityPub do
end
end
+ defp do_delete(%Object{data: %{"type" => "Tombstone", "id" => ap_id}}, _) do
+ activity =
+ ap_id
+ |> Activity.Queries.by_object_id()
+ |> Activity.Queries.by_type("Delete")
+ |> Repo.one()
+
+ {:ok, activity}
+ end
+
@spec block(User.t(), User.t(), String.t() | nil, boolean()) ::
{:ok, Activity.t()} | {:error, any()}
def block(blocker, blocked, activity_id \\ nil, local \\ true) do
diff --git a/test/web/activity_pub/activity_pub_test.exs b/test/web/activity_pub/activity_pub_test.exs
index a43dd34f0..049b14498 100644
--- a/test/web/activity_pub/activity_pub_test.exs
+++ b/test/web/activity_pub/activity_pub_test.exs
@@ -1425,6 +1425,12 @@ defmodule Pleroma.Web.ActivityPub.ActivityPubTest do
assert Repo.get(Object, object.id).data["type"] == "Tombstone"
end
+ test "it doesn't fail when an activity was already deleted" do
+ {:ok, delete} = insert(:note_activity) |> Object.normalize() |> ActivityPub.delete()
+
+ assert {:ok, ^delete} = delete |> Object.normalize() |> ActivityPub.delete()
+ end
+
test "decrements user note count only for public activities" do
user = insert(:user, note_count: 10)