From 165bf19f8c92be2dd66d80edcda838cc7f826545 Mon Sep 17 00:00:00 2001 From: alemi Date: Tue, 23 Apr 2024 23:37:57 +0200 Subject: [PATCH] feat: don't add next link when done paginating --- src/server/context.rs | 8 +++++++- 1 file changed, 7 insertions(+), 1 deletion(-) diff --git a/src/server/context.rs b/src/server/context.rs index f3df64d3..2010d394 100644 --- a/src/server/context.rs +++ b/src/server/context.rs @@ -236,8 +236,14 @@ impl Context { .set_id(Some(&format!("{id}?offset={offset}"))) .set_collection_type(Some(apb::CollectionType::OrderedCollectionPage)) .set_part_of(apb::Node::link(id.replace("/page", ""))) - .set_next(apb::Node::link(format!("{id}?offset={}", offset+limit))) .set_ordered_items(apb::Node::array(items)) + .set_next( + if items.len() < limit as usize { + apb::Node::Empty + } else { + apb::Node::link(format!("{id}?offset={}", offset+limit)) + } + ) } pub async fn dispatch(&self, uid: &str, activity_targets: Vec, aid: &str, oid: Option<&str>) -> crate::Result<()> {