[#1505] Removed wrapping of reply URIs into first
element, added comments to transmogrifier tests.
This commit is contained in:
parent
6ea3c06d8d
commit
24e49d14f2
@ -935,19 +935,9 @@ defp set_replies(obj, []) do
|
|||||||
end
|
end
|
||||||
|
|
||||||
defp set_replies(obj, replies_uris) do
|
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 = %{
|
replies_collection = %{
|
||||||
"type" => "Collection",
|
"type" => "Collection",
|
||||||
"id" => masto_replies_uri,
|
"items" => replies_uris
|
||||||
"first" => %{
|
|
||||||
"type" => "Collection",
|
|
||||||
"part_of" => masto_replies_uri,
|
|
||||||
"items" => replies_uris,
|
|
||||||
"next" => masto_replies_next_page_uri
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
Map.merge(obj, %{"replies" => replies_collection})
|
Map.merge(obj, %{"replies" => replies_collection})
|
||||||
|
@ -1361,6 +1361,7 @@ test "it accepts Move activities" do
|
|||||||
%{data: data, items: items, collection: collection}
|
%{data: data, items: items, collection: collection}
|
||||||
end
|
end
|
||||||
|
|
||||||
|
# Mastodon wraps reply URIs in `replies->first->items`
|
||||||
test "with wrapped `replies` collection, it schedules background fetching of items", %{
|
test "with wrapped `replies` collection, it schedules background fetching of items", %{
|
||||||
data: data,
|
data: data,
|
||||||
items: items,
|
items: items,
|
||||||
@ -1378,6 +1379,7 @@ test "with wrapped `replies` collection, it schedules background fetching of ite
|
|||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
|
# Pleroma outputs reply URIs as `replies->items`
|
||||||
test "it schedules background fetching of unwrapped `replies` collection items", %{
|
test "it schedules background fetching of unwrapped `replies` collection items", %{
|
||||||
data: data,
|
data: data,
|
||||||
items: items,
|
items: items,
|
||||||
@ -2135,10 +2137,8 @@ test "sets `replies` collection with a limited number of self-replies" do
|
|||||||
object = Object.normalize(activity)
|
object = Object.normalize(activity)
|
||||||
replies_uris = Enum.map([self_reply1, self_reply2], fn a -> a.object.data["id"] end)
|
replies_uris = Enum.map([self_reply1, self_reply2], fn a -> a.object.data["id"] end)
|
||||||
|
|
||||||
assert %{
|
assert %{"type" => "Collection", "items" => ^replies_uris} =
|
||||||
"type" => "Collection",
|
Transmogrifier.set_replies(object.data)["replies"]
|
||||||
"first" => %{"type" => "Collection", "items" => ^replies_uris}
|
|
||||||
} = Transmogrifier.set_replies(object.data)["replies"]
|
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
@ -51,10 +51,8 @@ test "renders `replies` collection for a note activity" do
|
|||||||
replies_uris = [self_reply1.object.data["id"]]
|
replies_uris = [self_reply1.object.data["id"]]
|
||||||
result = ObjectView.render("object.json", %{object: refresh_record(activity)})
|
result = ObjectView.render("object.json", %{object: refresh_record(activity)})
|
||||||
|
|
||||||
assert %{
|
assert %{"type" => "Collection", "items" => ^replies_uris} =
|
||||||
"type" => "Collection",
|
get_in(result, ["object", "replies"])
|
||||||
"first" => %{"type" => "Collection", "items" => ^replies_uris}
|
|
||||||
} = get_in(result, ["object", "replies"])
|
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user