activitypub transmogrifier: send Rejects in the format Mastodon wants
authorWilliam Pitcock <nenolod@dereferenced.org>
Sun, 27 May 2018 09:10:46 +0000 (09:10 +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 5f5ed7b8e101bea71bbc72090f140e7689f45ec1..170bfbc037c9f37ae989b1fc55f683bd1473f789 100644 (file)
@@ -456,6 +456,26 @@ defmodule Pleroma.Web.ActivityPub.Transmogrifier do
     end
   end
 
+  def prepare_outgoing(%{"type" => "Reject"} = data) do
+    with follow_activity <- Activity.get_by_ap_id(data["object"]) do
+      object = %{
+        "actor" => follow_activity.actor,
+        "object" => follow_activity.data["object"],
+        "id" => follow_activity.data["id"],
+        "type" => "Follow"
+      }
+
+      data =
+        data
+        |> Map.put("object", object)
+        |> Map.put("@context", "https://www.w3.org/ns/activitystreams")
+
+      IO.inspect(data)
+
+      {:ok, data}
+    end
+  end
+
   def prepare_outgoing(%{"type" => _type} = data) do
     data =
       data