activitypub transmogrifier: accept/reject outgoing: we might send the actual object...
authorWilliam Pitcock <nenolod@dereferenced.org>
Tue, 29 May 2018 10:18:23 +0000 (10:18 +0000)
committerWilliam Pitcock <nenolod@dereferenced.org>
Mon, 11 Jun 2018 22:15:53 +0000 (22:15 +0000)
lib/pleroma/web/activity_pub/transmogrifier.ex

index 08173f78db161671d947a7e5a787ff7283563c81..e7a3420d2d17f077b5a8efad5dc08288b71eb786 100644 (file)
@@ -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"],