From e55f69a676eab6ab30f15bdab2a4141a5f6ccf75 Mon Sep 17 00:00:00 2001 From: Francis Dinh Date: Tue, 8 May 2018 23:50:19 -0400 Subject: [PATCH] Handle Undo activites containing an Announce --- lib/pleroma/web/activity_pub/transmogrifier.ex | 20 +++++++++++++++++++- 1 file changed, 19 insertions(+), 1 deletion(-) diff --git a/lib/pleroma/web/activity_pub/transmogrifier.ex b/lib/pleroma/web/activity_pub/transmogrifier.ex index 2871a2544..8785ddaa9 100644 --- a/lib/pleroma/web/activity_pub/transmogrifier.ex +++ b/lib/pleroma/web/activity_pub/transmogrifier.ex @@ -220,9 +220,27 @@ defmodule Pleroma.Web.ActivityPub.Transmogrifier do end end + def handle_incoming( + %{ + "type" => "Undo", + "object" => %{"type" => "Announce", "id" => object_id}, + "actor" => actor, + "id" => id + } = data + ) do + with %User{} = actor <- User.get_or_fetch_by_ap_id(actor), + {:ok, object} <- + get_obj_helper(object_id) || ActivityPub.fetch_object_from_id(object_id), + {:ok, activity} <- ActivityPub.unannounce(object, false) do + {:ok, activity} + else + e -> :error + end + end + # TODO # Accept - # Undo + # Undo for non-Announce def handle_incoming(_), do: :error