[#1505] Removed wrapping of reply URIs into `first` element, added comments to transm...
authorIvan Tashkinov <ivantashkinov@gmail.com>
Sun, 9 Feb 2020 14:34:48 +0000 (17:34 +0300)
committerIvan Tashkinov <ivantashkinov@gmail.com>
Sun, 9 Feb 2020 14:34:48 +0000 (17:34 +0300)
lib/pleroma/web/activity_pub/transmogrifier.ex
test/web/activity_pub/transmogrifier_test.exs
test/web/activity_pub/views/object_view_test.exs

index 343228b370ef10b5ef5e11448409976b742c4b7a..6f09b4994b6b26f78866a4c5babbc0b64a991d63 100644 (file)
@@ -935,19 +935,9 @@ defmodule Pleroma.Web.ActivityPub.Transmogrifier do
   end
 
   defp set_replies(obj, replies_uris) do
-    # Note: stubs (Mastodon doesn't make separate requests via those URIs in FetchRepliesService)
-    masto_replies_uri = nil
-    masto_replies_next_page_uri = nil
-
     replies_collection = %{
       "type" => "Collection",
-      "id" => masto_replies_uri,
-      "first" => %{
-        "type" => "Collection",
-        "part_of" => masto_replies_uri,
-        "items" => replies_uris,
-        "next" => masto_replies_next_page_uri
-      }
+      "items" => replies_uris
     }
 
     Map.merge(obj, %{"replies" => replies_collection})
index d373762ea9a9d61b1cf185ca5422018825ed1710..7d9828d38539c4268c93a64e3c382f286f464516 100644 (file)
@@ -1361,6 +1361,7 @@ defmodule Pleroma.Web.ActivityPub.TransmogrifierTest do
       %{data: data, items: items, collection: collection}
     end
 
+    # Mastodon wraps reply URIs in `replies->first->items`
     test "with wrapped `replies` collection, it schedules background fetching of items", %{
       data: data,
       items: items,
@@ -1378,6 +1379,7 @@ defmodule Pleroma.Web.ActivityPub.TransmogrifierTest do
       end
     end
 
+    # Pleroma outputs reply URIs as `replies->items`
     test "it schedules background fetching of unwrapped `replies` collection items", %{
       data: data,
       items: items,
@@ -2135,10 +2137,8 @@ defmodule Pleroma.Web.ActivityPub.TransmogrifierTest do
       object = Object.normalize(activity)
       replies_uris = Enum.map([self_reply1, self_reply2], fn a -> a.object.data["id"] end)
 
-      assert %{
-               "type" => "Collection",
-               "first" => %{"type" => "Collection", "items" => ^replies_uris}
-             } = Transmogrifier.set_replies(object.data)["replies"]
+      assert %{"type" => "Collection", "items" => ^replies_uris} =
+               Transmogrifier.set_replies(object.data)["replies"]
     end
   end
 end
index a9197b0c579f1a591b452367ee59d1ca411035d0..acc855b98e57a75e6e5cd63638d7cf2471acb65d 100644 (file)
@@ -51,10 +51,8 @@ defmodule Pleroma.Web.ActivityPub.ObjectViewTest do
       replies_uris = [self_reply1.object.data["id"]]
       result = ObjectView.render("object.json", %{object: refresh_record(activity)})
 
-      assert %{
-               "type" => "Collection",
-               "first" => %{"type" => "Collection", "items" => ^replies_uris}
-             } = get_in(result, ["object", "replies"])
+      assert %{"type" => "Collection", "items" => ^replies_uris} =
+               get_in(result, ["object", "replies"])
     end
   end