Skip to content
Snippets Groups Projects
Commit f87a2eba authored by rswindell's avatar rswindell
Browse files

Tracker1's modification to set the "to" field of posted messages based on the

from field of the message referenced in "references" header field (if present).
parent 07bd1581
No related branches found
No related tags found
No related merge requests found
...@@ -39,6 +39,35 @@ function writeln(str) ...@@ -39,6 +39,35 @@ function writeln(str)
write(str + "\r\n"); write(str + "\r\n");
} }
// Courtesy of Michael J. Ryan <tracker1@theroughnecks.com>
function getReferenceTo(reference) {
//sbbs msg_id pattern.
var re = /^.*<[^\.]+\.([\d]+)\.([^@]+)@[^>]*>\s*$/;
//Default Response
var to = "All"
//if TO is already established, return...
if (reference=="")
return to;
//Load the msgbase the original post was from
if (!reference.match(re))
return to;
var sub = reference.replace(re,"$2");
var msg = parseInt(reference.replace(re,"$1"));
var msgbase = new MsgBase(sub);
if (msgbase != null) {
var hdr = msgbase.get_msg_header(false,msg);
if (hdr != null)
to = hdr.from;
}
return to;
}
var username=''; var username='';
var msgbase=null; var msgbase=null;
var selected=null; var selected=null;
...@@ -46,7 +75,7 @@ var current_article=0; ...@@ -46,7 +75,7 @@ var current_article=0;
writeln(format("200 %s News (Synchronet NNTP Service v%s)",system.name,VERSION)); writeln(format("200 %s News (Synchronet NNTP Service v%s)",system.name,VERSION));
if(!no_anonymous) if(!no_anonymous)
login("guest"); // Login as guest/anonymous by default login("guest"); // Login as guest/anonymous by default
while(client.socket.is_connected) { while(client.socket.is_connected) {
...@@ -79,7 +108,7 @@ while(client.socket.is_connected) { ...@@ -79,7 +108,7 @@ while(client.socket.is_connected) {
writeln("381 More authentication required"); writeln("381 More authentication required");
break; break;
case "PASS": case "PASS":
if(login(username,cmd[2])) if(login(username,cmd[2]))
writeln("281 Authentication successful"); writeln("281 Authentication successful");
else else
writeln("502 Authentication failure"); writeln("502 Authentication failure");
...@@ -113,7 +142,7 @@ while(client.socket.is_connected) { ...@@ -113,7 +142,7 @@ while(client.socket.is_connected) {
case "LIST": case "LIST":
writeln("215 list of newsgroups follows"); writeln("215 list of newsgroups follows");
for(g in msg_area.grp_list) for(g in msg_area.grp_list)
for(s in msg_area.grp_list[g].sub_list) { for(s in msg_area.grp_list[g].sub_list) {
msgbase=new MsgBase(msg_area.grp_list[g].sub_list[s].code); msgbase=new MsgBase(msg_area.grp_list[g].sub_list[s].code);
writeln(format("%s %u %u %s" writeln(format("%s %u %u %s"
...@@ -134,8 +163,8 @@ while(client.socket.is_connected) { ...@@ -134,8 +163,8 @@ while(client.socket.is_connected) {
case "GROUP": case "GROUP":
found=false; found=false;
for(g in msg_area.grp_list) for(g in msg_area.grp_list)
for(s in msg_area.grp_list[g].sub_list) for(s in msg_area.grp_list[g].sub_list)
if(msg_area.grp_list[g].sub_list[s].newsgroup.toLowerCase()==cmd[1].toLowerCase()) { if(msg_area.grp_list[g].sub_list[s].newsgroup.toLowerCase()==cmd[1].toLowerCase()) {
found=true; found=true;
msgbase=new MsgBase(msg_area.grp_list[g].sub_list[s].code); msgbase=new MsgBase(msg_area.grp_list[g].sub_list[s].code);
...@@ -254,7 +283,7 @@ while(client.socket.is_connected) { ...@@ -254,7 +283,7 @@ while(client.socket.is_connected) {
if(cmd[1]!='') { if(cmd[1]!='') {
if(cmd[1].indexOf('<')>=0) /* message-id */ if(cmd[1].indexOf('<')>=0) /* message-id */
current_article=Number(cmd[1].slice(1,-1)); current_article=Number(cmd[1].slice(1,-1));
else else
current_article=Number(cmd[1]); current_article=Number(cmd[1]);
} }
if(current_article<1) { if(current_article<1) {
...@@ -265,12 +294,12 @@ while(client.socket.is_connected) { ...@@ -265,12 +294,12 @@ while(client.socket.is_connected) {
hdr=null; hdr=null;
body=null; body=null;
hdr=msgbase.get_msg_header(false,current_article); hdr=msgbase.get_msg_header(false,current_article);
if(cmd[0].toUpperCase()!="HEAD") if(cmd[0].toUpperCase()!="HEAD")
body=msgbase.get_msg_body(false,current_article body=msgbase.get_msg_body(false,current_article
,true /* remove ctrl-a codes */); ,true /* remove ctrl-a codes */);
/* Eliminate dupe loops /* Eliminate dupe loops
if(user.security.restrictions&UFLAG_Q && hdr!=null) if(user.security.restrictions&UFLAG_Q && hdr!=null)
*/ */
if(hdr==null) { if(hdr==null) {
writeln("430 no such arctile found"); writeln("430 no such arctile found");
...@@ -284,8 +313,8 @@ while(client.socket.is_connected) { ...@@ -284,8 +313,8 @@ while(client.socket.is_connected) {
writeln("430 deleted message"); writeln("430 deleted message");
break; break;
} }
if(hdr.attr&MSG_PRIVATE if(hdr.attr&MSG_PRIVATE
&& hdr.to.toLowerCase()!=user.alias.toLowerCase() && hdr.to.toLowerCase()!=user.alias.toLowerCase()
&& hdr.to.toLowerCase()!=user.name.toLowerCase()) { && hdr.to.toLowerCase()!=user.name.toLowerCase()) {
writeln("430 private message"); writeln("430 private message");
break; break;
...@@ -435,6 +464,8 @@ while(client.socket.is_connected) { ...@@ -435,6 +464,8 @@ while(client.socket.is_connected) {
break; break;
case "references": case "references":
hdr.reply_id=data; hdr.reply_id=data;
if(!hdr.to)
hdr.to=getReferenceTo(data);
break; break;
case "newsgroups": case "newsgroups":
newsgroups=data.split(','); newsgroups=data.split(',');
...@@ -452,9 +483,9 @@ while(client.socket.is_connected) { ...@@ -452,9 +483,9 @@ while(client.socket.is_connected) {
break; break;
} }
for(n in newsgroups) for(n in newsgroups)
for(g in msg_area.grp_list) for(g in msg_area.grp_list)
for(s in msg_area.grp_list[g].sub_list) for(s in msg_area.grp_list[g].sub_list)
if(msg_area.grp_list[g].sub_list[s].newsgroup.toLowerCase() if(msg_area.grp_list[g].sub_list[s].newsgroup.toLowerCase()
==newsgroups[n].toLowerCase()) { ==newsgroups[n].toLowerCase()) {
if(!msg_area.grp_list[g].sub_list[s].can_post) if(!msg_area.grp_list[g].sub_list[s].can_post)
...@@ -474,7 +505,7 @@ while(client.socket.is_connected) { ...@@ -474,7 +505,7 @@ while(client.socket.is_connected) {
writeln("240 article posted ok"); writeln("240 article posted ok");
posted=true; posted=true;
msgs_posted++; msgs_posted++;
} else } else
log(format("!ERROR saving mesage: %s",msgbase.last_error)); log(format("!ERROR saving mesage: %s",msgbase.last_error));
} }
if(!posted) { if(!posted) {
...@@ -490,7 +521,7 @@ while(client.socket.is_connected) { ...@@ -490,7 +521,7 @@ while(client.socket.is_connected) {
} }
} }
// Log statistics // Log statistics
if(msgs_read) if(msgs_read)
log(format("%u messages read",msgs_read)); log(format("%u messages read",msgs_read));
...@@ -498,3 +529,4 @@ if(msgs_posted) ...@@ -498,3 +529,4 @@ if(msgs_posted)
log(format("%u messages posted",msgs_posted)); log(format("%u messages posted",msgs_posted));
/* End of nntpservice.js */ /* End of nntpservice.js */
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment