mirror of
https://git.alemi.dev/fedimut.git
synced 2024-11-23 08:54:47 +01:00
fix: pagination
how was this not broken before??? pleroma works in mysterious ways
This commit is contained in:
parent
5f1fbe8422
commit
6ff112f6b6
1 changed files with 5 additions and 0 deletions
|
@ -83,6 +83,7 @@ impl FediClient {
|
|||
|
||||
async fn get_related_users(&self, user_id: &str, relation: &str) -> reqwest::Result<Vec<model::FediUser>> {
|
||||
let mut out = Vec::new();
|
||||
let mut max_id = String::new();
|
||||
let limit = 40; // TODO make it customizable? idk
|
||||
loop {
|
||||
let mut page : Vec<model::FediUser> = 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
|
||||
}
|
||||
|
|
Loading…
Reference in a new issue