aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--lib/pleroma/activity.ex6
-rw-r--r--lib/pleroma/web/ostatus/handlers/delete_handler.ex1
-rw-r--r--test/web/ostatus/incoming_documents/delete_handling_test.exs5
3 files changed, 12 insertions, 0 deletions
diff --git a/lib/pleroma/activity.ex b/lib/pleroma/activity.ex
index 0b7188aba..f226c4c5f 100644
--- a/lib/pleroma/activity.ex
+++ b/lib/pleroma/activity.ex
@@ -15,11 +15,17 @@ defmodule Pleroma.Activity do
where: fragment("(?)->>'id' = ?", activity.data, ^to_string(ap_id)))
end
+ # Wrong name, only returns create activities
def all_by_object_ap_id_q(ap_id) do
from activity in Activity,
where: fragment("(?)->'object'->>'id' = ?", activity.data, ^to_string(ap_id))
end
+ def all_non_create_by_object_ap_id_q(ap_id) do
+ from activity in Activity,
+ where: fragment("(?)->>'object' = ?", activity.data, ^to_string(ap_id))
+ end
+
def all_by_object_ap_id(ap_id) do
Repo.all(all_by_object_ap_id_q(ap_id))
end
diff --git a/lib/pleroma/web/ostatus/handlers/delete_handler.ex b/lib/pleroma/web/ostatus/handlers/delete_handler.ex
index 2e5f9469b..f54a037a0 100644
--- a/lib/pleroma/web/ostatus/handlers/delete_handler.ex
+++ b/lib/pleroma/web/ostatus/handlers/delete_handler.ex
@@ -7,6 +7,7 @@ defmodule Pleroma.Web.OStatus.DeleteHandler 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
end
diff --git a/test/web/ostatus/incoming_documents/delete_handling_test.exs b/test/web/ostatus/incoming_documents/delete_handling_test.exs
index 8cd6e295e..989c87afa 100644
--- a/test/web/ostatus/incoming_documents/delete_handling_test.exs
+++ b/test/web/ostatus/incoming_documents/delete_handling_test.exs
@@ -9,12 +9,17 @@ defmodule Pleroma.Web.OStatus.DeleteHandlingTest do
test "it removes the mentioned activity" do
note = insert(:note_activity)
second_note = insert(:note_activity)
+ user = insert(:user)
+ object = Object.get_by_ap_id(note.data["object"]["id"])
+
+ {:ok, like, object} = Pleroma.Web.ActivityPub.ActivityPub.like(user, object)
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)
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"])