From 437829a83376b9094689469d7d4c30eab48f556e Mon Sep 17 00:00:00 2001 From: default Date: Sun, 17 Nov 2024 11:08:25 +0100 Subject: [PATCH] mastoapi: more tweaks to notifications code. --- mastoapi.c | 16 ++++++++++++---- 1 file changed, 12 insertions(+), 4 deletions(-) diff --git a/mastoapi.c b/mastoapi.c index f80c730..73b9a8b 100644 --- a/mastoapi.c +++ b/mastoapi.c @@ -1727,11 +1727,11 @@ int mastoapi_get_handler(const xs_dict *req, const char *q_path, if (logged_in) { xs *l = notify_list(&snac1, 0, 64); xs *out = xs_list_new(); - xs_list *p = l; const xs_dict *v; const xs_list *excl = xs_dict_get(args, "exclude_types[]"); + const char *max_id = xs_dict_get(args, "max_id"); - while (xs_list_iter(&p, &v)) { + xs_list_foreach(l, v) { xs *noti = notify_get(&snac1, v); if (noti == NULL) @@ -1740,6 +1740,8 @@ int mastoapi_get_handler(const xs_dict *req, const char *q_path, const char *type = xs_dict_get(noti, "type"); const char *utype = xs_dict_get(noti, "utype"); const char *objid = xs_dict_get(noti, "objid"); + const char *id = xs_dict_get(noti, "id"); + xs *fid = xs_replace(id, ".", ""); xs *actor = NULL; xs *entry = NULL; @@ -1752,6 +1754,13 @@ int mastoapi_get_handler(const xs_dict *req, const char *q_path, if (is_hidden(&snac1, objid)) continue; + if (max_id) { + if (strcmp(fid, max_id) == 0) + max_id = NULL; + + continue; + } + /* convert the type */ if (strcmp(type, "Like") == 0 || strcmp(type, "EmojiReact") == 0) type = "favourite"; @@ -1778,8 +1787,7 @@ int mastoapi_get_handler(const xs_dict *req, const char *q_path, mn = xs_dict_append(mn, "type", type); - xs *id = xs_replace(xs_dict_get(noti, "id"), ".", ""); - mn = xs_dict_append(mn, "id", id); + mn = xs_dict_append(mn, "id", fid); mn = xs_dict_append(mn, "created_at", xs_dict_get(noti, "date"));