fix: oops no go back i do it all in fe

This commit is contained in:
əlemi 2024-11-09 13:43:27 +01:00
parent 48768b0e1a
commit 4a4625f8e4
Signed by: alemi
GPG key ID: A4895B84D311642C
5 changed files with 7 additions and 12 deletions

View file

@ -120,6 +120,5 @@ pub async fn page<const OUTGOING: bool>(
&upub::url!(ctx, "/actors/{id}/{follow___}/page"), &upub::url!(ctx, "/actors/{id}/{follow___}/page"),
offset, limit, offset, limit,
following.into_iter().map(serde_json::Value::String).collect(), following.into_iter().map(serde_json::Value::String).collect(),
true
) )
} }

View file

@ -52,6 +52,6 @@ pub async fn page(
.map(|x| x.ap()) .map(|x| x.ap())
.collect(); .collect();
crate::builders::collection_page(&upub::url!(ctx, "/actors/{id}/notifications/page"), offset, limit, activities, true) crate::builders::collection_page(&upub::url!(ctx, "/actors/{id}/notifications/page"), offset, limit, activities)
} }

View file

@ -51,5 +51,5 @@ pub async fn page(
.map(|item| item.ap()) .map(|item| item.ap())
.collect(); .collect();
crate::builders::collection_page(&id, offset, limit, items, true) crate::builders::collection_page(&id, offset, limit, items)
} }

View file

@ -47,7 +47,6 @@ pub async fn page(
offset, offset,
limit, limit,
objects, objects,
true,
) )
} }

View file

@ -21,9 +21,7 @@ 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
let replies = page.replies.unwrap_or(true); if !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());
} }
@ -54,19 +52,18 @@ pub async fn paginate_feed(
.map(|item| item.ap()) .map(|item| item.ap())
.collect(); .collect();
collection_page(&id, offset, limit, items, replies) collection_page(&id, offset, limit, items)
} }
pub fn collection_page(id: &str, offset: u64, limit: u64, items: Vec<serde_json::Value>, replies: bool) -> crate::ApiResult<JsonLD<serde_json::Value>> { pub fn collection_page(id: &str, offset: u64, limit: u64, items: Vec<serde_json::Value>) -> 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={}{replies}", offset+limit)) apb::Node::link(format!("{id}?offset={}", offset+limit))
}; };
Ok(JsonLD( Ok(JsonLD(
apb::new() apb::new()
.set_id(Some(&format!("{id}?offset={offset}{replies}"))) .set_id(Some(&format!("{id}?offset={offset}")))
.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))