Skip to content
Snippets Groups Projects
Commit 0ed73e64 authored by echicken's avatar echicken :chicken:
Browse files

Include total count of threads when returning a subset.

parent 16a79e9f
No related branches found
No related tags found
1 merge request!463MRC mods by Codefenix (2024-10-20)
...@@ -59,14 +59,14 @@ function listThreads(sub, offset, count) { ...@@ -59,14 +59,14 @@ function listThreads(sub, offset, count) {
if (offset >= threads.order.length) return false; if (offset >= threads.order.length) return false;
var stop = Math.min(threads.order.length, offset + count); var stop = Math.min(threads.order.length, offset + count);
var ret = []; var ret = { total: threads.order.length, threads : [] };
for (var n = offset; n < stop; n++) { for (var n = offset; n < stop; n++) {
var thread = threads.thread[threads.order[n]]; var thread = threads.thread[threads.order[n]];
var msgs = Object.keys(thread.messages); var msgs = Object.keys(thread.messages);
thread.first = thread.messages[msgs[0]]; thread.first = thread.messages[msgs[0]];
thread.last = thread.messages[msgs[msgs.length - 1]]; thread.last = thread.messages[msgs[msgs.length - 1]];
thread.messages = msgs.length; thread.messages = msgs.length;
ret.push(thread); ret.threads.push(thread);
} }
return ret; return ret;
...@@ -1085,4 +1085,17 @@ function getMessageThreads(sub, max) { ...@@ -1085,4 +1085,17 @@ function getMessageThreads(sub, max) {
} }
function isValidRequest() {
if (Req.has_param('group')) {
const grp = Req.get_param('group');
if (typeof msg_area.grp_list[grp] == 'undefined') return false;
if (!user.compare_ars(msg_area.grp_list[grp].ars)) return false;
}
if (Req.has_param('sub')) {
const sub = Req.get_param('sub');
if (typeof msg_area.sub[sub] == 'undefined') return false;
}
return true;
}
this; this;
...@@ -218,7 +218,7 @@ if ((http_request.method === 'GET' || http_request.method === 'POST') && ...@@ -218,7 +218,7 @@ if ((http_request.method === 'GET' || http_request.method === 'POST') &&
http_request.query.sub[0], http_request.query.sub[0],
http_request.query.offset[0], http_request.query.offset[0],
count || settings.page_size count || settings.page_size
); ).threads;
} }
break; break;
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment