fix: include replies choice in next page urls
This commit is contained in:
parent
baaaa55e9d
commit
aaed94d2f8
1 changed files with 8 additions and 5 deletions
|
@ -21,7 +21,9 @@ pub async fn paginate_feed(
|
||||||
.add(filter);
|
.add(filter);
|
||||||
|
|
||||||
// by default we want replies because servers don't know about our api and want everything
|
// 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());
|
conditions = conditions.add(upub::model::object::Column::InReplyTo.is_null());
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -52,18 +54,19 @@ pub async fn paginate_feed(
|
||||||
.map(|item| item.ap())
|
.map(|item| item.ap())
|
||||||
.collect();
|
.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<serde_json::Value>) -> crate::ApiResult<JsonLD<serde_json::Value>> {
|
pub fn collection_page(id: &str, offset: u64, limit: u64, items: Vec<serde_json::Value>, replies: bool) -> crate::ApiResult<JsonLD<serde_json::Value>> {
|
||||||
|
let replies = if replies { "" } else { "&replies=false" };
|
||||||
let next = if items.len() < limit as usize {
|
let next = if items.len() < limit as usize {
|
||||||
apb::Node::Empty
|
apb::Node::Empty
|
||||||
} else {
|
} else {
|
||||||
apb::Node::link(format!("{id}?offset={}", offset+limit))
|
apb::Node::link(format!("{id}?offset={}{replies}", offset+limit))
|
||||||
};
|
};
|
||||||
Ok(JsonLD(
|
Ok(JsonLD(
|
||||||
apb::new()
|
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_collection_type(Some(apb::CollectionType::OrderedCollectionPage))
|
||||||
.set_part_of(apb::Node::link(id.replace("/page", "")))
|
.set_part_of(apb::Node::link(id.replace("/page", "")))
|
||||||
.set_ordered_items(apb::Node::array(items))
|
.set_ordered_items(apb::Node::array(items))
|
||||||
|
|
Loading…
Reference in a new issue