X-Git-Url: http://git.bytex64.net/?a=blobdiff_plain;f=cgi%2Fcgi_blerg.c;fp=cgi%2Fcgi_blerg.c;h=9df908baae256d3356e825e00bfdc1fdf2c42609;hb=2ed464c9a551f74387dd8a719df6a0fe3760ab10;hp=de325c3748838196162d7e73c411e0f2b6c28237;hpb=32321bfee03406ebbcb13542def0a75b00426ac5;p=blerg.git diff --git a/cgi/cgi_blerg.c b/cgi/cgi_blerg.c index de325c3..9df908b 100644 --- a/cgi/cgi_blerg.c +++ b/cgi/cgi_blerg.c @@ -342,36 +342,30 @@ int main(int argc, char *argv[]) { auth_logout(ac.name, ac.token); respond_JSON_Success(); - } else if (strncmp(path, "/subscribe", 10) == 0 || strncmp(path, "/unsubscribe", 12) == 0) { + } else if (strncmp(path, "/subscribe", 10) == 0) { if (!check_auth(&ac)) exit(0); - if (path[1] == 'u') { - if (path[12] != '/') { - respond_404(); - exit(0); - } - - ret = parse_url_info(path + 13, &info); - if ((ret & URL_INFO_NAME) == 0) { - respond_404(); - exit(0); - } + if (path[10] != '/') { + respond_404(); + exit(0); + } - subscription_remove(ac.name, info.name); - } else { - if (path[10] != '/') { - respond_404(); - exit(0); - } + ret = parse_url_info(path + 11, &info); + if ((ret & URL_INFO_NAME) == 0) { + respond_404(); + exit(0); + } - ret = parse_url_info(path + 11, &info); - if ((ret & URL_INFO_NAME) == 0) { - respond_404(); - exit(0); - } + const char *subscribed = cgi_getentrystr("subscribed"); + if (strncmp(subscribed, "true", 4) == 0) { subscription_add(ac.name, info.name); + } else if (strncmp(subscribed, "false", 5) == 0) { + subscription_remove(ac.name, info.name); + } else { + respond_JSON_Failure(); + exit(0); } respond_JSON_Success(); } else if (strncmp(path, "/feed", 6) == 0) {