diff options
author | feld <feld@feld.me> | 2020-03-24 19:10:32 +0000 |
---|---|---|
committer | rinpatch <rinpatch@sdf.org> | 2020-03-31 13:40:28 +0300 |
commit | 10b7b2b4a42773c5ab0f69379418728da68b5ce0 (patch) | |
tree | c81d78d49e34c868704293984f92e55eea7400cb | |
parent | 0e92aa0025fbdb268735502cae0a434558e290c5 (diff) | |
download | pleroma-10b7b2b4a42773c5ab0f69379418728da68b5ce0.tar.gz |
Merge branch 'fix/activity-deletion' into 'develop'
Fix activity deletion
Closes #1640
See merge request pleroma/pleroma!2328
-rw-r--r-- | lib/pleroma/web/activity_pub/activity_pub.ex | 10 | ||||
-rw-r--r-- | test/web/activity_pub/activity_pub_test.exs | 6 |
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 60e74758f..eaaaba775 100644 --- a/lib/pleroma/web/activity_pub/activity_pub.ex +++ b/lib/pleroma/web/activity_pub/activity_pub.ex @@ -584,6 +584,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 3dd3dd04d..433859dab 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) |