about summary refs log tree commit diff
path: root/kittybox-rs/src/frontend/mod.rs
diff options
context:
space:
mode:
Diffstat (limited to 'kittybox-rs/src/frontend/mod.rs')
-rw-r--r--kittybox-rs/src/frontend/mod.rs13
1 files changed, 7 insertions, 6 deletions
diff --git a/kittybox-rs/src/frontend/mod.rs b/kittybox-rs/src/frontend/mod.rs
index b90d57c..d677005 100644
--- a/kittybox-rs/src/frontend/mod.rs
+++ b/kittybox-rs/src/frontend/mod.rs
@@ -79,13 +79,13 @@ async fn get_post_from_database<S: Storage>(
     url: &str,
     after: Option<String>,
     user: &Option<String>,
-) -> std::result::Result<serde_json::Value, FrontendError> {
+) -> std::result::Result<(serde_json::Value, Option<String>), FrontendError> {
     match db
-        .read_feed_with_limit(url, &after, POSTS_PER_PAGE, user)
+        .read_feed_with_cursor(url, after.as_deref(), POSTS_PER_PAGE, user.as_deref())
         .await
     {
         Ok(result) => match result {
-            Some(post) => Ok(post),
+            Some((post, cursor)) => Ok((post, cursor)),
             None => Err(FrontendError::with_code(
                 StatusCode::NOT_FOUND,
                 "Post not found in the database",
@@ -125,7 +125,7 @@ pub async fn homepage<D: Storage>(
         get_post_from_database(&db, &path, None, &user),
         get_post_from_database(&db, &feed_path, query.after, &user)
     ) {
-        Ok((hcard, hfeed)) => {
+        Ok(((hcard, _), (hfeed, cursor))) => {
             // Here, we know those operations can't really fail
             // (or it'll be a transient failure that will show up on
             // other requests anyway if it's serious...)
@@ -155,6 +155,7 @@ pub async fn homepage<D: Storage>(
                     content: MainPage {
                         feed: &hfeed,
                         card: &hcard,
+                        cursor: cursor.as_deref(),
                         webring: crate::database::settings::Setting::into_inner(webring)
                     }
                     .to_string(),
@@ -219,7 +220,7 @@ pub async fn catchall<D: Storage>(
         .unwrap();
 
     match get_post_from_database(&db, path.as_str(), query.after, &user).await {
-        Ok(post) => {
+        Ok((post, cursor)) => {
             let (blogname, channels) = tokio::join!(
                 db.get_setting::<crate::database::settings::SiteName>(&host)
                 .map(Result::unwrap_or_default),
@@ -240,7 +241,7 @@ pub async fn catchall<D: Storage>(
                     user,
                     content: match post.pointer("/type/0").and_then(|i| i.as_str()) {
                         Some("h-entry") => Entry { post: &post }.to_string(),
-                        Some("h-feed") => Feed { feed: &post }.to_string(),
+                        Some("h-feed") => Feed { feed: &post, cursor: cursor.as_deref() }.to_string(),
                         Some("h-card") => VCard { card: &post }.to_string(),
                         unknown => {
                             unimplemented!("Template for MF2-JSON type {:?}", unknown)