From 6ff112f6b6d47b49264bde66b4483264cfe69e69 Mon Sep 17 00:00:00 2001 From: alemi Date: Thu, 7 Mar 2024 18:56:21 +0100 Subject: [PATCH] fix: pagination how was this not broken before??? pleroma works in mysterious ways --- src/main.rs | 5 +++++ 1 file changed, 5 insertions(+) diff --git a/src/main.rs b/src/main.rs index 4327f8c..a0e3cb6 100644 --- a/src/main.rs +++ b/src/main.rs @@ -83,6 +83,7 @@ impl FediClient { async fn get_related_users(&self, user_id: &str, relation: &str) -> reqwest::Result> { let mut out = Vec::new(); + let mut max_id = String::new(); let limit = 40; // TODO make it customizable? idk loop { let mut page : Vec = self.http @@ -90,12 +91,16 @@ impl FediClient { .headers(self.headers()) .query(&[("limit", limit)]) .query(&[("with_relationships", true)]) + .query(&[("max_id", &max_id)]) .send() .await? .error_for_status()? .json() .await?; let count = page.len(); + if let Some(u) = page.last() { + max_id = u.id.clone(); + } out.append(&mut page); // TODO can i just concat these vecs at the end? if count != limit { break } // end of pages }