diff options
author | default <nobody@localhost> | 2024-02-05 10:18:38 +0100 |
---|---|---|
committer | default <nobody@localhost> | 2024-02-05 10:18:38 +0100 |
commit | 729ad476f081e0ea63f90263ce5959b9889356f9 (patch) | |
tree | 8e9e7e4949b587493aecebc4538d2d6a8979d1d8 /data.c | |
parent | 823cb05fe53e364c4421512a9f1263ed54662de0 (diff) |
notify_list() no longer has a new_only argument.
Diffstat (limited to 'data.c')
-rw-r--r-- | data.c | 35 |
1 files changed, 25 insertions, 10 deletions
@@ -2064,15 +2064,34 @@ xs_dict *notify_get(snac *snac, const char *id) } -xs_list *notify_list(snac *snac, int new_only) -/* returns a list of notification ids, optionally only the new ones */ +int notify_new_num(snac *snac) +/* counts the number of new notifications */ { - xs *t = NULL; + xs *t = notify_check_time(snac, 0); + xs *spec = xs_fmt("%s/notify/" "*.json", snac->basedir); + xs *lst = xs_glob(spec, 1, 1); + int cnt = 0; + + xs_list *p = lst; + xs_str *v; + + while (xs_list_iter(&p, &v)) { + xs *id = xs_replace(v, ".json", ""); - /* if only new ones are requested, get the last time */ - if (new_only) - t = notify_check_time(snac, 0); + /* old? count no more */ + if (strcmp(id, t) < 0) + break; + cnt++; + } + + return cnt; +} + + +xs_list *notify_list(snac *snac) +/* returns a list of notification ids, optionally only the new ones */ +{ xs *spec = xs_fmt("%s/notify/" "*.json", snac->basedir); xs *lst = xs_glob(spec, 1, 1); xs_list *out = xs_list_new(); @@ -2082,10 +2101,6 @@ xs_list *notify_list(snac *snac, int new_only) while (xs_list_iter(&p, &v)) { xs *id = xs_replace(v, ".json", ""); - /* old? */ - if (t != NULL && strcmp(id, t) < 0) - continue; - out = xs_list_append(out, id); } |