From d96377f3590c08a2c38941299aedb977b1b5a8e5 Mon Sep 17 00:00:00 2001 From: William Pitcock Date: Tue, 29 May 2018 10:18:23 +0000 Subject: [PATCH] activitypub transmogrifier: accept/reject outgoing: we might send the actual object instead of the URI in some cases, handle it --- lib/pleroma/web/activity_pub/transmogrifier.ex | 18 ++++++++++++++++-- 1 file changed, 16 insertions(+), 2 deletions(-) diff --git a/lib/pleroma/web/activity_pub/transmogrifier.ex b/lib/pleroma/web/activity_pub/transmogrifier.ex index 08173f78d..e7a3420d2 100644 --- a/lib/pleroma/web/activity_pub/transmogrifier.ex +++ b/lib/pleroma/web/activity_pub/transmogrifier.ex @@ -443,7 +443,14 @@ defmodule Pleroma.Web.ActivityPub.Transmogrifier do # Mastodon Accept/Reject requires a non-normalized object containing the actor URIs, # because of course it does. def prepare_outgoing(%{"type" => "Accept"} = data) do - with follow_activity <- Activity.get_by_ap_id(data["object"]) do + follow_activity_id = + if is_binary(data["object"]) do + data["object"] + else + data["object"]["id"] + end + + with follow_activity <- Activity.get_by_ap_id(follow_activity_id) do object = %{ "actor" => follow_activity.actor, "object" => follow_activity.data["object"], @@ -461,7 +468,14 @@ defmodule Pleroma.Web.ActivityPub.Transmogrifier do end def prepare_outgoing(%{"type" => "Reject"} = data) do - with follow_activity <- Activity.get_by_ap_id(data["object"]) do + follow_activity_id = + if is_binary(data["object"]) do + data["object"] + else + data["object"]["id"] + end + + with follow_activity <- Activity.get_by_ap_id(follow_activity_id) do object = %{ "actor" => follow_activity.actor, "object" => follow_activity.data["object"], -- 2.45.2