Merge branch 'outbox_pagination' into 'develop'
Fix AP outbox pagination See merge request pleroma/pleroma!1700
This commit is contained in:
commit
b80c41a14f
@ -227,11 +227,12 @@ def render("outbox.json", %{user: user, max_id: max_qid}) do
|
|||||||
|
|
||||||
activities = ActivityPub.fetch_user_activities(user, nil, params)
|
activities = ActivityPub.fetch_user_activities(user, nil, params)
|
||||||
|
|
||||||
|
# this is sorted chronologically, so first activity is the newest (max)
|
||||||
{max_id, min_id, collection} =
|
{max_id, min_id, collection} =
|
||||||
if length(activities) > 0 do
|
if length(activities) > 0 do
|
||||||
{
|
{
|
||||||
Enum.at(Enum.reverse(activities), 0).id,
|
|
||||||
Enum.at(activities, 0).id,
|
Enum.at(activities, 0).id,
|
||||||
|
Enum.at(Enum.reverse(activities), 0).id,
|
||||||
Enum.map(activities, fn act ->
|
Enum.map(activities, fn act ->
|
||||||
{:ok, data} = Transmogrifier.prepare_outgoing(act.data)
|
{:ok, data} = Transmogrifier.prepare_outgoing(act.data)
|
||||||
data
|
data
|
||||||
|
@ -142,4 +142,27 @@ test "sets correct totalItems when follows are hidden but the follow counter is
|
|||||||
assert %{"totalItems" => 1} = UserView.render("following.json", %{user: user})
|
assert %{"totalItems" => 1} = UserView.render("following.json", %{user: user})
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
|
test "outbox paginates correctly" do
|
||||||
|
user = insert(:user)
|
||||||
|
|
||||||
|
posts =
|
||||||
|
for i <- 0..25 do
|
||||||
|
{:ok, activity} = CommonAPI.post(user, %{"status" => "post #{i}"})
|
||||||
|
activity
|
||||||
|
end
|
||||||
|
|
||||||
|
# outbox sorts chronologically, newest first, with ten per page
|
||||||
|
posts = Enum.reverse(posts)
|
||||||
|
|
||||||
|
%{"first" => %{"next" => next_url}} =
|
||||||
|
UserView.render("outbox.json", %{user: user, max_id: nil})
|
||||||
|
|
||||||
|
next_id = Enum.at(posts, 9).id
|
||||||
|
assert next_url =~ next_id
|
||||||
|
|
||||||
|
%{"next" => next_url} = UserView.render("outbox.json", %{user: user, max_id: next_id})
|
||||||
|
next_id = Enum.at(posts, 19).id
|
||||||
|
assert next_url =~ next_id
|
||||||
|
end
|
||||||
end
|
end
|
||||||
|
Loading…
Reference in New Issue
Block a user