summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorGravatar default2023-04-14 19:39:31 +0200
committerGravatar default2023-04-14 19:39:31 +0200
commit9e7a77c10f0bf3e4d9c99ff8c188476ca9c62a92 (patch)
tree80ec39655d24a8a175852de671ff300f238c52a4
parentSet the timeline check time after showing the notifications. (diff)
downloadsnac2-9e7a77c10f0bf3e4d9c99ff8c188476ca9c62a92.tar.gz
snac2-9e7a77c10f0bf3e4d9c99ff8c188476ca9c62a92.tar.xz
snac2-9e7a77c10f0bf3e4d9c99ff8c188476ca9c62a92.zip
New mastoapi to clear all notifications.
-rw-r--r--data.c13
-rw-r--r--mastoapi.c13
-rw-r--r--snac.h1
3 files changed, 27 insertions, 0 deletions
diff --git a/data.c b/data.c
index 9f2e462..4e5696e 100644
--- a/data.c
+++ b/data.c
@@ -1595,6 +1595,19 @@ xs_list *notify_list(snac *snac, int new_only)
1595} 1595}
1596 1596
1597 1597
1598void notify_clear(snac *snac)
1599/* clears all notifications */
1600{
1601 xs *spec = xs_fmt("%s/notify/" "*", snac->basedir);
1602 xs *lst = xs_glob(spec, 0, 0);
1603 xs_list *p = lst;
1604 xs_str *v;
1605
1606 while (xs_list_iter(&p, &v))
1607 unlink(v);
1608}
1609
1610
1598/** the queue **/ 1611/** the queue **/
1599 1612
1600static xs_dict *_enqueue_put(const char *fn, xs_dict *msg) 1613static xs_dict *_enqueue_put(const char *fn, xs_dict *msg)
diff --git a/mastoapi.c b/mastoapi.c
index f9141d0..d07d012 100644
--- a/mastoapi.c
+++ b/mastoapi.c
@@ -1290,6 +1290,19 @@ int mastoapi_post_handler(const xs_dict *req, const char *q_path,
1290 else 1290 else
1291 status = 401; 1291 status = 401;
1292 } 1292 }
1293 else
1294 if (strcmp(cmd, "/notifications/clear") == 0) {
1295 if (logged_in) {
1296 notify_clear(&snac);
1297 timeline_touch(&snac);
1298
1299 *body = xs_dup("{}");
1300 *ctype = "application/json";
1301 status = 200;
1302 }
1303 else
1304 status = 401;
1305 }
1293 1306
1294 /* user cleanup */ 1307 /* user cleanup */
1295 if (logged_in) 1308 if (logged_in)
diff --git a/snac.h b/snac.h
index 17bd361..d65b5ac 100644
--- a/snac.h
+++ b/snac.h
@@ -143,6 +143,7 @@ void notify_add(snac *snac, const char *type, const char *utype,
143 const char *actor, const char *objid); 143 const char *actor, const char *objid);
144xs_dict *notify_get(snac *snac, const char *id); 144xs_dict *notify_get(snac *snac, const char *id);
145xs_list *notify_list(snac *snac, int new_only); 145xs_list *notify_list(snac *snac, int new_only);
146void notify_clear(snac *snac);
146 147
147void inbox_add(const char *inbox); 148void inbox_add(const char *inbox);
148void inbox_add_by_actor(const xs_dict *actor); 149void inbox_add_by_actor(const xs_dict *actor);