diff options
| author | 2023-04-14 19:39:31 +0200 | |
|---|---|---|
| committer | 2023-04-14 19:39:31 +0200 | |
| commit | 9e7a77c10f0bf3e4d9c99ff8c188476ca9c62a92 (patch) | |
| tree | 80ec39655d24a8a175852de671ff300f238c52a4 | |
| parent | Set the timeline check time after showing the notifications. (diff) | |
| download | snac2-9e7a77c10f0bf3e4d9c99ff8c188476ca9c62a92.tar.gz snac2-9e7a77c10f0bf3e4d9c99ff8c188476ca9c62a92.tar.xz snac2-9e7a77c10f0bf3e4d9c99ff8c188476ca9c62a92.zip | |
New mastoapi to clear all notifications.
| -rw-r--r-- | data.c | 13 | ||||
| -rw-r--r-- | mastoapi.c | 13 | ||||
| -rw-r--r-- | snac.h | 1 |
3 files changed, 27 insertions, 0 deletions
| @@ -1595,6 +1595,19 @@ xs_list *notify_list(snac *snac, int new_only) | |||
| 1595 | } | 1595 | } |
| 1596 | 1596 | ||
| 1597 | 1597 | ||
| 1598 | void 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 | ||
| 1600 | static xs_dict *_enqueue_put(const char *fn, xs_dict *msg) | 1613 | static xs_dict *_enqueue_put(const char *fn, xs_dict *msg) |
| @@ -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) |
| @@ -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); |
| 144 | xs_dict *notify_get(snac *snac, const char *id); | 144 | xs_dict *notify_get(snac *snac, const char *id); |
| 145 | xs_list *notify_list(snac *snac, int new_only); | 145 | xs_list *notify_list(snac *snac, int new_only); |
| 146 | void notify_clear(snac *snac); | ||
| 146 | 147 | ||
| 147 | void inbox_add(const char *inbox); | 148 | void inbox_add(const char *inbox); |
| 148 | void inbox_add_by_actor(const xs_dict *actor); | 149 | void inbox_add_by_actor(const xs_dict *actor); |