Synchronet now requires the libarchive development package (e.g. libarchive-dev on Debian-based Linux distros, libarchive.org for more info) to build successfully.

Commit 48296d04 authored by echicken's avatar echicken 🐔

Added get-thread call, support for generatorish reply value. list-threads...

Added get-thread call, support for generatorish reply value. list-threads doesn't need offset, instead will begin at the message after 'after' if given.
parent c4b4434f
......@@ -160,6 +160,13 @@ if (Request.has_param('call') && (http_request.method === 'GET' || http_request.
}
break;
case 'get-thread':
if (Request.has_params(['sub', 'thread'])) {
if (Request.has_param('count')) var count = Request.get_param('count');
reply = getMessageThread(Request.get_param('sub'), Request.get_param('thread'), count || settings.page_size, Request.get_param('after'));
}
break;
case 'list-groups':
reply = listGroups();
break;
......@@ -169,9 +176,9 @@ if (Request.has_param('call') && (http_request.method === 'GET' || http_request.
break;
case 'list-threads':
if (Request.has_params(['sub', 'offset'])) {
if (Request.has_param('count')) var count = http_request.query.count[0];
reply = listThreads(http_request.query.sub[0], http_request.query.offset[0], count || settings.page_size).threads;
if (Request.has_param('sub')) {
if (Request.has_param('count')) var count = Request.get_param(count);
reply = listThreads(Request.get_param('sub'), count || settings.page_size, Request.get_param('after'));
}
break;
......@@ -188,7 +195,15 @@ if (Request.has_param('call') && (http_request.method === 'GET' || http_request.
}
reply = JSON.stringify(reply);
http_reply.header['Content-Type'] = 'application/json';
http_reply.header['Content-Length'] = reply.length;
write(reply);
if (typeof reply === 'function') { // generator
var r;
http_reply.header['Content-Type'] = 'application/json';
while ((r = reply()) !== null) {
writeln(JSON.stringify(r));
}
} else { // Normal reply
reply = JSON.stringify(reply);
http_reply.header['Content-Type'] = 'application/json';
http_reply.header['Content-Length'] = reply.length;
write(reply);
}
\ No newline at end of file
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment