mirror of
https://codeberg.org/grunfink/snac2.git
synced 2024-11-22 05:15:04 +00:00
notify_list() no longer has a new_only argument.
This commit is contained in:
parent
823cb05fe5
commit
729ad476f0
4 changed files with 31 additions and 16 deletions
37
data.c
37
data.c
|
@ -2064,15 +2064,34 @@ xs_dict *notify_get(snac *snac, const char *id)
|
|||
}
|
||||
|
||||
|
||||
xs_list *notify_list(snac *snac, int new_only)
|
||||
int notify_new_num(snac *snac)
|
||||
/* counts the number of new notifications */
|
||||
{
|
||||
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", "");
|
||||
|
||||
/* 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 *t = NULL;
|
||||
|
||||
/* if only new ones are requested, get the last time */
|
||||
if (new_only)
|
||||
t = notify_check_time(snac, 0);
|
||||
|
||||
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);
|
||||
}
|
||||
|
||||
|
|
5
html.c
5
html.c
|
@ -673,8 +673,7 @@ static xs_html *html_user_body(snac *user, int local)
|
|||
xs_html_text(L("private"))));
|
||||
}
|
||||
else {
|
||||
xs *n_list = notify_list(user, 1);
|
||||
int n_len = xs_list_len(n_list);
|
||||
int n_len = notify_new_num(user);
|
||||
xs_html *notify_count = NULL;
|
||||
|
||||
/* show the number of new notifications, if there are any */
|
||||
|
@ -2138,7 +2137,7 @@ xs_str *html_people(snac *user)
|
|||
|
||||
xs_str *html_notifications(snac *user)
|
||||
{
|
||||
xs *n_list = notify_list(user, 0);
|
||||
xs *n_list = notify_list(user);
|
||||
xs *n_time = notify_check_time(user, 0);
|
||||
|
||||
xs_html *body = html_user_body(user, 0);
|
||||
|
|
|
@ -1542,7 +1542,7 @@ int mastoapi_get_handler(const xs_dict *req, const char *q_path,
|
|||
else
|
||||
if (strcmp(cmd, "/v1/notifications") == 0) { /** **/
|
||||
if (logged_in) {
|
||||
xs *l = notify_list(&snac1, 0);
|
||||
xs *l = notify_list(&snac1);
|
||||
xs *out = xs_list_new();
|
||||
xs_list *p = l;
|
||||
xs_dict *v;
|
||||
|
|
3
snac.h
3
snac.h
|
@ -187,7 +187,8 @@ xs_str *notify_check_time(snac *snac, int reset);
|
|||
void notify_add(snac *snac, const char *type, const char *utype,
|
||||
const char *actor, const char *objid);
|
||||
xs_dict *notify_get(snac *snac, const char *id);
|
||||
xs_list *notify_list(snac *snac, int new_only);
|
||||
int notify_new_num(snac *snac);
|
||||
xs_list *notify_list(snac *snac);
|
||||
void notify_clear(snac *snac);
|
||||
|
||||
void inbox_add(const char *inbox);
|
||||
|
|
Loading…
Reference in a new issue