From 2348b272e020bd22520a4306be5f2fdc8469cfd1 Mon Sep 17 00:00:00 2001 From: Roger Braun Date: Mon, 4 Sep 2017 18:47:46 +0200 Subject: [PATCH] Create deletes activities for incoming deletes. --- lib/pleroma/web/ostatus/handlers/delete_handler.ex | 9 ++++----- .../ostatus/incoming_documents/delete_handling_test.exs | 4 +++- 2 files changed, 7 insertions(+), 6 deletions(-) diff --git a/lib/pleroma/web/ostatus/handlers/delete_handler.ex b/lib/pleroma/web/ostatus/handlers/delete_handler.ex index f54a037a0..29fe4052c 100644 --- a/lib/pleroma/web/ostatus/handlers/delete_handler.ex +++ b/lib/pleroma/web/ostatus/handlers/delete_handler.ex @@ -2,14 +2,13 @@ defmodule Pleroma.Web.OStatus.DeleteHandler do require Logger alias Pleroma.Web.{XML, OStatus} alias Pleroma.{Activity, Object, Repo} + alias Pleroma.Web.ActivityPub.ActivityPub def handle_delete(entry, doc \\ nil) do with id <- XML.string_from_xpath("//id", entry), - object when not is_nil(object) <- Object.get_by_ap_id(id) do - Repo.delete(object) - Repo.delete_all(Activity.all_non_create_by_object_ap_id_q(id)) - Repo.delete_all(Activity.all_by_object_ap_id_q(id)) - nil + object when not is_nil(object) <- Object.get_by_ap_id(id), + {:ok, delete} <- ActivityPub.delete(object, false) do + delete end end end diff --git a/test/web/ostatus/incoming_documents/delete_handling_test.exs b/test/web/ostatus/incoming_documents/delete_handling_test.exs index 989c87afa..74c6a5994 100644 --- a/test/web/ostatus/incoming_documents/delete_handling_test.exs +++ b/test/web/ostatus/incoming_documents/delete_handling_test.exs @@ -16,13 +16,15 @@ test "it removes the mentioned activity" do incoming = File.read!("test/fixtures/delete.xml") |> String.replace("tag:mastodon.sdf.org,2017-06-10:objectId=310513:objectType=Status", note.data["object"]["id"]) - {:ok, []} = OStatus.handle_incoming(incoming) + {:ok, [delete]} = OStatus.handle_incoming(incoming) refute Repo.get(Activity, note.id) refute Repo.get(Activity, like.id) refute Object.get_by_ap_id(note.data["object"]["id"]) assert Repo.get(Activity, second_note.id) assert Object.get_by_ap_id(second_note.data["object"]["id"]) + + assert delete.data["type"] == "Delete" end end end