chore: refactor and deprecate pagination builder
This commit is contained in:
parent
69071c1320
commit
cc090ccb19
5 changed files with 8 additions and 8 deletions
|
@ -118,6 +118,6 @@ pub async fn page<const OUTGOING: bool>(
|
|||
crate::builders::collection_page(
|
||||
&upub::url!(ctx, "/actors/{id}/{follow___}/page"),
|
||||
offset, limit,
|
||||
following.into_iter().map(serde_json::Value::String).collect(),
|
||||
apb::Node::links(following),
|
||||
)
|
||||
}
|
||||
|
|
|
@ -51,6 +51,6 @@ pub async fn page(
|
|||
.map(|x| ctx.ap(x))
|
||||
.collect();
|
||||
|
||||
crate::builders::collection_page(&upub::url!(ctx, "/actors/{id}/notifications/page"), offset, limit, activities)
|
||||
crate::builders::collection_page(&upub::url!(ctx, "/actors/{id}/notifications/page"), offset, limit, apb::Node::array(activities))
|
||||
|
||||
}
|
||||
|
|
|
@ -51,5 +51,5 @@ pub async fn page(
|
|||
.map(|item| ctx.ap(item))
|
||||
.collect();
|
||||
|
||||
crate::builders::collection_page(&upub::url!(ctx, "/objects/{id}/context/page"), offset, limit, items)
|
||||
crate::builders::collection_page(&upub::url!(ctx, "/objects/{id}/context/page"), offset, limit, apb::Node::array(items))
|
||||
}
|
||||
|
|
|
@ -45,7 +45,7 @@ pub async fn page(
|
|||
&upub::url!(ctx, "/tags/{id}/page"),
|
||||
offset,
|
||||
limit,
|
||||
objects,
|
||||
apb::Node::array(objects),
|
||||
)
|
||||
|
||||
}
|
||||
|
|
|
@ -5,7 +5,7 @@ use upub::selector::{BatchFillable, RichActivity};
|
|||
|
||||
use crate::activitypub::Pagination;
|
||||
|
||||
//#[deprecated = "use upub::Query directly"]
|
||||
#[deprecated = "use upub::Query directly"]
|
||||
pub async fn paginate_feed(
|
||||
id: String,
|
||||
filter: Condition,
|
||||
|
@ -52,10 +52,10 @@ pub async fn paginate_feed(
|
|||
.map(|item| ctx.ap(item))
|
||||
.collect();
|
||||
|
||||
collection_page(&id, offset, limit, items)
|
||||
collection_page(&id, offset, limit, apb::Node::array(items))
|
||||
}
|
||||
|
||||
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: apb::Node<serde_json::Value>) -> crate::ApiResult<JsonLD<serde_json::Value>> {
|
||||
let next = if items.len() < limit as usize {
|
||||
apb::Node::Empty
|
||||
} else {
|
||||
|
@ -66,7 +66,7 @@ pub fn collection_page(id: &str, offset: u64, limit: u64, items: Vec<serde_json:
|
|||
.set_id(Some(format!("{id}?offset={offset}")))
|
||||
.set_collection_type(Some(apb::CollectionType::OrderedCollectionPage))
|
||||
.set_part_of(apb::Node::link(id.replace("/page", "")))
|
||||
.set_ordered_items(apb::Node::array(items))
|
||||
.set_ordered_items(items)
|
||||
.set_next(next)
|
||||
.ld_context()
|
||||
))
|
||||
|
|
Loading…
Reference in a new issue