diff --git a/upub/routes/src/builders.rs b/upub/routes/src/builders.rs index 51be453..5931f38 100644 --- a/upub/routes/src/builders.rs +++ b/upub/routes/src/builders.rs @@ -21,7 +21,9 @@ pub async fn paginate_feed( .add(filter); // by default we want replies because servers don't know about our api and want everything - if !page.replies.unwrap_or(true) { + let replies = page.replies.unwrap_or(true); + + if !replies { conditions = conditions.add(upub::model::object::Column::InReplyTo.is_null()); } @@ -52,18 +54,19 @@ pub async fn paginate_feed( .map(|item| item.ap()) .collect(); - collection_page(&id, offset, limit, items) + collection_page(&id, offset, limit, items, replies) } -pub fn collection_page(id: &str, offset: u64, limit: u64, items: Vec) -> crate::ApiResult> { +pub fn collection_page(id: &str, offset: u64, limit: u64, items: Vec, replies: bool) -> crate::ApiResult> { + let replies = if replies { "" } else { "&replies=false" }; let next = if items.len() < limit as usize { apb::Node::Empty } else { - apb::Node::link(format!("{id}?offset={}", offset+limit)) + apb::Node::link(format!("{id}?offset={}{replies}", offset+limit)) }; Ok(JsonLD( apb::new() - .set_id(Some(&format!("{id}?offset={offset}"))) + .set_id(Some(&format!("{id}?offset={offset}{replies}"))) .set_collection_type(Some(apb::CollectionType::OrderedCollectionPage)) .set_part_of(apb::Node::link(id.replace("/page", ""))) .set_ordered_items(apb::Node::array(items))