mirror of
https://codeberg.org/grunfink/snac2.git
synced 2024-11-22 13:25:04 +00:00
New mastoapi to clear all notifications.
This commit is contained in:
parent
58b2a47631
commit
9e7a77c10f
3 changed files with 27 additions and 0 deletions
13
data.c
13
data.c
|
@ -1595,6 +1595,19 @@ xs_list *notify_list(snac *snac, int new_only)
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
void notify_clear(snac *snac)
|
||||||
|
/* clears all notifications */
|
||||||
|
{
|
||||||
|
xs *spec = xs_fmt("%s/notify/" "*", snac->basedir);
|
||||||
|
xs *lst = xs_glob(spec, 0, 0);
|
||||||
|
xs_list *p = lst;
|
||||||
|
xs_str *v;
|
||||||
|
|
||||||
|
while (xs_list_iter(&p, &v))
|
||||||
|
unlink(v);
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
/** the queue **/
|
/** the queue **/
|
||||||
|
|
||||||
static xs_dict *_enqueue_put(const char *fn, xs_dict *msg)
|
static xs_dict *_enqueue_put(const char *fn, xs_dict *msg)
|
||||||
|
|
13
mastoapi.c
13
mastoapi.c
|
@ -1290,6 +1290,19 @@ int mastoapi_post_handler(const xs_dict *req, const char *q_path,
|
||||||
else
|
else
|
||||||
status = 401;
|
status = 401;
|
||||||
}
|
}
|
||||||
|
else
|
||||||
|
if (strcmp(cmd, "/notifications/clear") == 0) {
|
||||||
|
if (logged_in) {
|
||||||
|
notify_clear(&snac);
|
||||||
|
timeline_touch(&snac);
|
||||||
|
|
||||||
|
*body = xs_dup("{}");
|
||||||
|
*ctype = "application/json";
|
||||||
|
status = 200;
|
||||||
|
}
|
||||||
|
else
|
||||||
|
status = 401;
|
||||||
|
}
|
||||||
|
|
||||||
/* user cleanup */
|
/* user cleanup */
|
||||||
if (logged_in)
|
if (logged_in)
|
||||||
|
|
1
snac.h
1
snac.h
|
@ -143,6 +143,7 @@ void notify_add(snac *snac, const char *type, const char *utype,
|
||||||
const char *actor, const char *objid);
|
const char *actor, const char *objid);
|
||||||
xs_dict *notify_get(snac *snac, const char *id);
|
xs_dict *notify_get(snac *snac, const char *id);
|
||||||
xs_list *notify_list(snac *snac, int new_only);
|
xs_list *notify_list(snac *snac, int new_only);
|
||||||
|
void notify_clear(snac *snac);
|
||||||
|
|
||||||
void inbox_add(const char *inbox);
|
void inbox_add(const char *inbox);
|
||||||
void inbox_add_by_actor(const xs_dict *actor);
|
void inbox_add_by_actor(const xs_dict *actor);
|
||||||
|
|
Loading…
Reference in a new issue