commit 7f18d1c

grunfink  ·  2025-08-14 07:58:21 +0000 UTC
parent 5885589
mastoapi: avoid repeating entries.
1 files changed,  +6, -1
+6, -1
 1@@ -1397,6 +1397,9 @@ xs_list *mastoapi_timeline(snac *user, const xs_dict *args, const char *index_fn
 2         initial_status = index_desc_first(f, md5, 0);
 3     }
 4 
 5+    xs_set entries;
 6+    xs_set_init(&entries);
 7+
 8     if (initial_status) {
 9         do {
10             xs *msg = NULL;
11@@ -1488,7 +1491,7 @@ xs_list *mastoapi_timeline(snac *user, const xs_dict *args, const char *index_fn
12             /* convert the Note into a Mastodon status */
13             xs *st = mastoapi_status(user, msg);
14 
15-            if (st != NULL) {
16+            if (st != NULL && xs_set_add(&entries, md5) == 1) {
17                 if (ascending)
18                     out = xs_list_insert(out, 0, st);
19                 else
20@@ -1499,6 +1502,8 @@ xs_list *mastoapi_timeline(snac *user, const xs_dict *args, const char *index_fn
21         } while ((cnt < limit) && (*iterator)(f, md5));
22     }
23 
24+    xs_set_free(&entries);
25+
26     int more = index_desc_next(f, md5);
27 
28     fclose(f);