X-Git-Url: http://git.bytex64.net/?a=blobdiff_plain;f=cgi%2Fcgi_blerg.c;h=4d5541135d4cd9b5e11aae650a346a27df2e9f6e;hb=7a618c2e7e80b87b6462efd9b953e3297029c39e;hp=b479535b827df28d73748bda6be26d9e64515119;hpb=30465019b067284f33ffe514e970edcf3ca6f1e5;p=blerg.git diff --git a/cgi/cgi_blerg.c b/cgi/cgi_blerg.c index b479535..4d55411 100644 --- a/cgi/cgi_blerg.c +++ b/cgi/cgi_blerg.c @@ -376,26 +376,33 @@ int main(int argc, char *argv[]) { } else { respond_blergref_list(feedlist, recs); } + + struct blerg *b = blerg_open(username); + blerg_set_subscription_mark(b); + blerg_close(b); } else if (strncmp(path, "/feedinfo", 9) == 0) { const char *username = cgi_getentrystr("username"); if (!check_auth(username)) exit(0); - if (path[9] != '/') { - respond_404(); - exit(0); - } - - ret = parse_url_info(path + 10, &info); - if ((ret & URL_INFO_NAME) == 0) { - respond_404(); - exit(0); - } - yajl_gen g = yajl_gen_alloc(&yajl_c, NULL); yajl_gen_map_open(g); - yajl_gen_string(g, "subscribed", 10); - yajl_gen_bool(g, is_subscribed(username, info.name)); + if (path[9] == 0) { + struct blerg *b = blerg_open(username); + uint64_t subscription_mark = blerg_get_subscription_mark(b); + blerg_close(b); + + yajl_gen_string(g, "new", 3); + yajl_gen_integer(g, subscription_count_items(username) - subscription_mark); + } else { + yajl_gen_string(g, "subscribed", 10); + ret = parse_url_info(path + 10, &info); + if ((ret & URL_INFO_NAME) == 1) { + yajl_gen_bool(g, is_subscribed(username, info.name)); + } else { + yajl_gen_bool(g, 0); + } + } yajl_gen_map_close(g); const unsigned char *ybuf;