From 5d8ad897fde2693c57769710d61f974b7967eb4e Mon Sep 17 00:00:00 2001 From: Thomas Citharel Date: Tue, 12 Jan 2021 17:12:38 +0100 Subject: [PATCH] Fix collection next attribute and add prev attribute Closes #546 Signed-off-by: Thomas Citharel --- lib/web/views/activity_pub/actor_view.ex | 16 +++++++++++++--- 1 file changed, 13 insertions(+), 3 deletions(-) diff --git a/lib/web/views/activity_pub/actor_view.ex b/lib/web/views/activity_pub/actor_view.ex index 9ca6293b..0e61e75a 100644 --- a/lib/web/views/activity_pub/actor_view.ex +++ b/lib/web/views/activity_pub/actor_view.ex @@ -153,9 +153,19 @@ defmodule Mobilizon.Web.ActivityPub.ActorView do "orderedItems" => Enum.map(collection, &item/1) } - if offset < total do - Map.put(map, "next", Actor.build_url(preferred_username, endpoint, page: page + 1)) - end + map = + if offset < total do + Map.put(map, "next", Actor.build_url(preferred_username, endpoint, page: page + 1)) + else + map + end + + map = + if offset > total do + Map.put(map, "prev", Actor.build_url(preferred_username, endpoint, page: page - 1)) + else + map + end map end