summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorGravatar default2023-04-10 00:40:48 +0200
committerGravatar default2023-04-10 00:40:48 +0200
commita65f1911d4bb3fc31adec52b61f2c6d264172610 (patch)
treed46487f0a33e60aa5d02d23be51fc311095babea
parentMore mastoapi work. (diff)
downloadsnac2-a65f1911d4bb3fc31adec52b61f2c6d264172610.tar.gz
snac2-a65f1911d4bb3fc31adec52b61f2c6d264172610.tar.xz
snac2-a65f1911d4bb3fc31adec52b61f2c6d264172610.zip
Limit the number of entries returned using the max_id.
-rw-r--r--mastoapi.c13
1 files changed, 9 insertions, 4 deletions
diff --git a/mastoapi.c b/mastoapi.c
index 00adab6..c745c33 100644
--- a/mastoapi.c
+++ b/mastoapi.c
@@ -420,15 +420,20 @@ int mastoapi_get_handler(const xs_dict *req, const char *q_path,
420 limit = atoi(limit_s); 420 limit = atoi(limit_s);
421 421
422 xs *out = xs_list_new(); 422 xs *out = xs_list_new();
423 xs *timeline = timeline_list(&snac, "private", 0, limit); 423 xs *timeline = timeline_list(&snac, "private", 0, XS_ALL);
424 xs_list *p = timeline; 424 xs_list *p = timeline;
425 xs_str *v; 425 xs_str *v;
426 426
427 while (xs_list_iter(&p, &v) && cnt < limit) { 427 while (xs_list_iter(&p, &v) && cnt < limit) {
428 xs *msg = NULL; 428 xs *msg = NULL;
429 429
430 if (max_id) 430 /* only return entries older that max_id */
431 break; 431 if (max_id) {
432 if (strcmp(v, max_id) == 0)
433 max_id = NULL;
434
435 continue;
436 }
432 437
433 /* get the entry */ 438 /* get the entry */
434 if (!valid_status(timeline_get_by_md5(&snac, v, &msg))) 439 if (!valid_status(timeline_get_by_md5(&snac, v, &msg)))