diff --git a/html.c b/html.c index e448cd8..c9d9c86 100644 --- a/html.c +++ b/html.c @@ -289,14 +289,15 @@ d_char *html_user_header(snac *snac, d_char *s, int local) /* show the notification number, if there are any */ if (n_len) - n_str = xs_fmt(" %d ", n_len); + n_str = xs_fmt(" %d ", n_len); else n_str = xs_str_new(""); s1 = xs_fmt( "%s - " "%s - " - "%s%s - " + "%s%s - " "%s\n", snac->actor, L("public"), snac->actor, L("private"), @@ -1184,6 +1185,76 @@ d_char *html_people(snac *snac) } +xs_str *html_notifications(snac *snac) +{ + xs_str *s = xs_str_new(NULL); + xs *n_list = notify_list(snac, 0); + xs *n_time = notify_check_time(snac, 0); + xs_list *p = n_list; + xs_str *v; + enum { NHDR_NONE, NHDR_NEW, NHDR_OLD } stage = NHDR_NONE; + + s = html_user_header(snac, s, 0); + + while (xs_list_iter(&p, &v)) { + xs *noti = notify_get(snac, v); + + if (noti == NULL) + continue; + + xs *obj = NULL; + const char *type = xs_dict_get(noti, "type"); + const char *id = xs_dict_get(noti, strcmp(type, "Follow") == 0 ? "actor" : "objid"); + + if (!valid_status(object_get(id, &obj))) + continue; + + if (is_hidden(snac, id)) + continue; + + if (strcmp(v, n_time) > 0) { + /* unseen notification */ + if (stage == NHDR_NONE) { + xs *s1 = xs_fmt("
%s:
\n", strcmp("Create", type) == 0 ? "Mention" : type); + s = xs_str_cat(s, s1); + + xs *md5 = xs_md5_hex(id, strlen(id)); + s = html_entry(snac, s, obj, 0, 0, md5); + + s = xs_str_cat(s, "