summaryrefslogtreecommitdiff
path: root/data.c
diff options
context:
space:
mode:
Diffstat (limited to 'data.c')
-rw-r--r--data.c35
1 files changed, 25 insertions, 10 deletions
diff --git a/data.c b/data.c
index d9816a0..d644eb3 100644
--- a/data.c
+++ b/data.c
@@ -2064,15 +2064,34 @@ xs_dict *notify_get(snac *snac, const char *id)
2064} 2064}
2065 2065
2066 2066
2067xs_list *notify_list(snac *snac, int new_only) 2067int notify_new_num(snac *snac)
2068/* returns a list of notification ids, optionally only the new ones */ 2068/* counts the number of new notifications */
2069{ 2069{
2070 xs *t = NULL; 2070 xs *t = notify_check_time(snac, 0);
2071 xs *spec = xs_fmt("%s/notify/" "*.json", snac->basedir);
2072 xs *lst = xs_glob(spec, 1, 1);
2073 int cnt = 0;
2074
2075 xs_list *p = lst;
2076 xs_str *v;
2077
2078 while (xs_list_iter(&p, &v)) {
2079 xs *id = xs_replace(v, ".json", "");
2071 2080
2072 /* if only new ones are requested, get the last time */ 2081 /* old? count no more */
2073 if (new_only) 2082 if (strcmp(id, t) < 0)
2074 t = notify_check_time(snac, 0); 2083 break;
2075 2084
2085 cnt++;
2086 }
2087
2088 return cnt;
2089}
2090
2091
2092xs_list *notify_list(snac *snac)
2093/* returns a list of notification ids, optionally only the new ones */
2094{
2076 xs *spec = xs_fmt("%s/notify/" "*.json", snac->basedir); 2095 xs *spec = xs_fmt("%s/notify/" "*.json", snac->basedir);
2077 xs *lst = xs_glob(spec, 1, 1); 2096 xs *lst = xs_glob(spec, 1, 1);
2078 xs_list *out = xs_list_new(); 2097 xs_list *out = xs_list_new();
@@ -2082,10 +2101,6 @@ xs_list *notify_list(snac *snac, int new_only)
2082 while (xs_list_iter(&p, &v)) { 2101 while (xs_list_iter(&p, &v)) {
2083 xs *id = xs_replace(v, ".json", ""); 2102 xs *id = xs_replace(v, ".json", "");
2084 2103
2085 /* old? */
2086 if (t != NULL && strcmp(id, t) < 0)
2087 continue;
2088
2089 out = xs_list_append(out, id); 2104 out = xs_list_append(out, id);
2090 } 2105 }
2091 2106