mirror of
https://akkoma.dev/AkkomaGang/akkoma.git
synced 2024-11-19 03:35:02 +00:00
Create deletes activities for incoming deletes.
This commit is contained in:
parent
5db535c0b1
commit
2348b272e0
2 changed files with 7 additions and 6 deletions
|
@ -2,14 +2,13 @@ defmodule Pleroma.Web.OStatus.DeleteHandler do
|
||||||
require Logger
|
require Logger
|
||||||
alias Pleroma.Web.{XML, OStatus}
|
alias Pleroma.Web.{XML, OStatus}
|
||||||
alias Pleroma.{Activity, Object, Repo}
|
alias Pleroma.{Activity, Object, Repo}
|
||||||
|
alias Pleroma.Web.ActivityPub.ActivityPub
|
||||||
|
|
||||||
def handle_delete(entry, doc \\ nil) do
|
def handle_delete(entry, doc \\ nil) do
|
||||||
with id <- XML.string_from_xpath("//id", entry),
|
with id <- XML.string_from_xpath("//id", entry),
|
||||||
object when not is_nil(object) <- Object.get_by_ap_id(id) do
|
object when not is_nil(object) <- Object.get_by_ap_id(id),
|
||||||
Repo.delete(object)
|
{:ok, delete} <- ActivityPub.delete(object, false) do
|
||||||
Repo.delete_all(Activity.all_non_create_by_object_ap_id_q(id))
|
delete
|
||||||
Repo.delete_all(Activity.all_by_object_ap_id_q(id))
|
|
||||||
nil
|
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
|
@ -16,13 +16,15 @@ defmodule Pleroma.Web.OStatus.DeleteHandlingTest do
|
||||||
|
|
||||||
incoming = File.read!("test/fixtures/delete.xml")
|
incoming = File.read!("test/fixtures/delete.xml")
|
||||||
|> String.replace("tag:mastodon.sdf.org,2017-06-10:objectId=310513:objectType=Status", note.data["object"]["id"])
|
|> 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, note.id)
|
||||||
refute Repo.get(Activity, like.id)
|
refute Repo.get(Activity, like.id)
|
||||||
refute Object.get_by_ap_id(note.data["object"]["id"])
|
refute Object.get_by_ap_id(note.data["object"]["id"])
|
||||||
assert Repo.get(Activity, second_note.id)
|
assert Repo.get(Activity, second_note.id)
|
||||||
assert Object.get_by_ap_id(second_note.data["object"]["id"])
|
assert Object.get_by_ap_id(second_note.data["object"]["id"])
|
||||||
|
|
||||||
|
assert delete.data["type"] == "Delete"
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
Loading…
Reference in a new issue