commit 437829a

default  ·  2024-11-17 10:08:25 +0000 UTC
parent 442b46a
mastoapi: more tweaks to notifications code.
1 files changed,  +12, -4
+12, -4
 1@@ -1727,11 +1727,11 @@ int mastoapi_get_handler(const xs_dict *req, const char *q_path,
 2         if (logged_in) {
 3             xs *l      = notify_list(&snac1, 0, 64);
 4             xs *out    = xs_list_new();
 5-            xs_list *p = l;
 6             const xs_dict *v;
 7             const xs_list *excl = xs_dict_get(args, "exclude_types[]");
 8+            const char *max_id = xs_dict_get(args, "max_id");
 9 
10-            while (xs_list_iter(&p, &v)) {
11+            xs_list_foreach(l, v) {
12                 xs *noti = notify_get(&snac1, v);
13 
14                 if (noti == NULL)
15@@ -1740,6 +1740,8 @@ int mastoapi_get_handler(const xs_dict *req, const char *q_path,
16                 const char *type  = xs_dict_get(noti, "type");
17                 const char *utype = xs_dict_get(noti, "utype");
18                 const char *objid = xs_dict_get(noti, "objid");
19+                const char *id    = xs_dict_get(noti, "id");
20+                xs *fid = xs_replace(id, ".", "");
21                 xs *actor = NULL;
22                 xs *entry = NULL;
23 
24@@ -1752,6 +1754,13 @@ int mastoapi_get_handler(const xs_dict *req, const char *q_path,
25                 if (is_hidden(&snac1, objid))
26                     continue;
27 
28+                if (max_id) {
29+                    if (strcmp(fid, max_id) == 0)
30+                        max_id = NULL;
31+
32+                    continue;
33+                }
34+
35                 /* convert the type */
36                 if (strcmp(type, "Like") == 0 || strcmp(type, "EmojiReact") == 0)
37                     type = "favourite";
38@@ -1778,8 +1787,7 @@ int mastoapi_get_handler(const xs_dict *req, const char *q_path,
39 
40                 mn = xs_dict_append(mn, "type", type);
41 
42-                xs *id = xs_replace(xs_dict_get(noti, "id"), ".", "");
43-                mn = xs_dict_append(mn, "id", id);
44+                mn = xs_dict_append(mn, "id", fid);
45 
46                 mn = xs_dict_append(mn, "created_at", xs_dict_get(noti, "date"));
47