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 83465f65 authored by Rob Swindell's avatar Rob Swindell 💬

Optimize the newsgroup list part of previous commit.

Don't regenerate the newsgroup_list for *every* authenticated NNTP command.
parent d124e3fb
Pipeline #559 passed with stage
in 14 minutes and 25 seconds
...@@ -148,6 +148,21 @@ function count_msgs(msgbase) ...@@ -148,6 +148,21 @@ function count_msgs(msgbase)
return { total: count, first: first, last: last }; return { total: count, first: first, last: last };
} }
function get_newsgroup_list()
{
// list of newsgroup names the logged-in user has access to
var newsgroup_list = [];
if(include_mail) {
newsgroup_list.push("mail");
}
for(var g in msg_area.grp_list) {
for(var s in msg_area.grp_list[g].sub_list) {
newsgroup_list.push(msg_area.grp_list[g].sub_list[s].newsgroup);
}
}
return newsgroup_list;
}
function bogus_cmd(cmdline) function bogus_cmd(cmdline)
{ {
log(LOG_DEBUG, "Received bogus command: '" + cmdline + "'"); log(LOG_DEBUG, "Received bogus command: '" + cmdline + "'");
...@@ -288,17 +303,6 @@ while(client.socket.is_connected && !quit) { ...@@ -288,17 +303,6 @@ while(client.socket.is_connected && !quit) {
} }
} }
// list of newsgroup names the logged-in user has access to
var newsgroup_list = [];
if(include_mail) {
newsgroup_list.push("mail");
}
for(g in msg_area.grp_list) {
for(s in msg_area.grp_list[g].sub_list) {
newsgroup_list.push(msg_area.grp_list[g].sub_list[s].newsgroup);
}
}
/* These commands require login/authentication */ /* These commands require login/authentication */
switch(cmd[0].toUpperCase()) { switch(cmd[0].toUpperCase()) {
...@@ -778,17 +782,17 @@ while(client.socket.is_connected && !quit) { ...@@ -778,17 +782,17 @@ while(client.socket.is_connected && !quit) {
if(hdr.newsgroups==undefined || force_newsgroups) if(hdr.newsgroups==undefined || force_newsgroups)
hdr.newsgroups = selected.newsgroup; hdr.newsgroups = selected.newsgroup;
else { else {
var ng_list = hdr.newsgroups.split(','); var nghdr_list = hdr.newsgroups.split(',');
var newsgroup_list = get_newsgroup_list();
var filtered_list = []; var filtered_list = [];
for(n in ng_list) { for(var n in nghdr_list) {
if(filter_newsgroups && newsgroup_list.indexOf(ng_list[n]) < 0) if(filter_newsgroups && newsgroup_list.indexOf(nghdr_list[n]) < 0)
continue; continue;
filtered_list.push(ng_list[n]); filtered_list.push(nghdr_list[n]);
} }
hdr.newsgroups = filtered_list.join(',');
/* Tracker1's mod for adding the correct newsgroup name */
if(filtered_list.indexOf(selected.newsgroup) < 0) if(filtered_list.indexOf(selected.newsgroup) < 0)
hdr.newsgroups = selected.newsgroup + ',' + hdr.newsgroups; filtered_list.push(selected.newsgroup);
hdr.newsgroups = filtered_list.join(',');
} }
if(hdr.from_org==undefined && !hdr.from_net_type) if(hdr.from_org==undefined && !hdr.from_net_type)
......
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