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

Added support for configurable listserver address

(default: listserver@system.inet_addr).
config->names key renamed to config->aliases.
Added support for list descriptions (defaults to sub-board description).
Beginning of support for control commands.
Support for moderated contributions.
parent 07aea3b4
No related branches found
No related tags found
No related merge requests found
...@@ -18,7 +18,9 @@ if(!ini_file.open("r")) { ...@@ -18,7 +18,9 @@ if(!ini_file.open("r")) {
,ini_file.error, ini_fname)); ,ini_file.error, ini_fname));
exit(); exit();
} }
name_list=ini_file.iniGetValue("config","names",new Array()); listserver_address=ini_file.iniGetValue("config","address","listserver@"+system.inet_addr);
alias_list=ini_file.iniGetValue("config","aliases",new Array());
subj_cmd=ini_file.iniGetValue("config","SubjectCommand",false);
list_array=ini_file.iniGetAllObjects("name","list:"); list_array=ini_file.iniGetAllObjects("name","list:");
ini_file.close(); ini_file.close();
if(!list_array.length) { if(!list_array.length) {
...@@ -26,10 +28,13 @@ if(!list_array.length) { ...@@ -26,10 +28,13 @@ if(!list_array.length) {
exit(); exit();
} }
/* Set default list addresses */ for(var l in list_array) {
for(var l in list_array) /* Set default list addresses */
if(!list_array[l].address) if(!list_array[l].address)
list_array[l].address = format("%s@%s", list_array[l].name, system.inet_addr); list_array[l].address = format("%s@%s", list_array[l].name, system.inet_addr);
if(!list_array[l].description)
list_array[l].description = msg_area.sub[list_array[l].sub].description;
}
/* Inbound message from SMTP Server? */ /* Inbound message from SMTP Server? */
if(this.recipient_list_filename!=undefined) { if(this.recipient_list_filename!=undefined) {
...@@ -52,12 +57,11 @@ if(this.recipient_list_filename!=undefined) { ...@@ -52,12 +57,11 @@ if(this.recipient_list_filename!=undefined) {
var msgtxt_file = new File(message_text_filename); var msgtxt_file = new File(message_text_filename);
if(!msgtxt_file.open("r")) { if(!msgtxt_file.open("r")) {
error_file.writeln(log(LOG_ERR,format("!ERROR %s opening recipient list: %s" error_file.writeln(log(LOG_ERR,format("!ERROR %s opening message text: %s"
,msgtxt_file.error, message_text_filename))); ,msgtxt_file.error, message_text_filename)));
exit(); exit();
} }
var msgtxt = msgtxt_file.readAll()
msgtxt = msgtxt_file.readAll()
msgtxt_file.close(); msgtxt_file.close();
load("mailproc_util.js"); // import parse_msg_header() and get_msg_body() load("mailproc_util.js"); // import parse_msg_header() and get_msg_body()
...@@ -68,11 +72,13 @@ if(this.recipient_list_filename!=undefined) { ...@@ -68,11 +72,13 @@ if(this.recipient_list_filename!=undefined) {
var r; var r;
/* control message for list server? */ /* control message for list server? */
for(r=0;r<rcpt_list.length;r++) { for(r=0;r<rcpt_list.length;r++) {
for(n=0;n<name_list.length;n++) { if(rcpt_list[r].Recipient.toLowerCase()==listserver_address.toLowerCase())
if(rcpt_list[r].Recipient.search(new RegExp(name_list[n],"i"))!=-1) break;
for(n=0;n<alias_list.length;n++) {
if(rcpt_list[r].Recipient.search(new RegExp(alias_list[n],"i"))!=-1)
break; break;
} }
if(n<name_list.length) /* match found */ if(n<alias_list.length) /* match found */
break; break;
} }
if(r<rcpt_list.length) { if(r<rcpt_list.length) {
...@@ -80,13 +86,43 @@ if(this.recipient_list_filename!=undefined) { ...@@ -80,13 +86,43 @@ if(this.recipient_list_filename!=undefined) {
log(LOG_INFO,format("ListServer Control message from %s to %s: %s" log(LOG_INFO,format("ListServer Control message from %s to %s: %s"
,header.from, header.to, header.subject)); ,header.from, header.to, header.subject));
process_control_msg(header, body); if(subj_cmd)
body.unshift(header.subject); /* Process the subject as a command */
body=process_control_msg(body);
header.to=header.from;
header.form=listserver_address;
/* Write response to message */
if(!msgtxt_file.open("w")) {
error_file.writeln(log(LOG_ERR,format("!ERROR %s opening message text: %s"
,msgtxt_file.error, message_text_filename)));
exit();
}
for(h in header)
msgtxt_file.writeln(h+": "+header[h]);
msgtxt_file.writeln();
msgtxt_file.writeAll(body);
msgtxt_file.close();
/* Re-write the recipient list */
if(!rcptlst_file.open("w")) {
error_file.writeln(log(LOG_ERR,format("!ERROR %s opening recipient list: %s"
,rcptlst_file.error, recipient_list_filename)));
exit();
}
rcptlst_file.writeln("[0]");
rcptlst_file.writeln("Recipient="+header.to);
rcptlst_file.writeln("RecipientAgent="+AGENT_PROCESS);
rcptlst_file.writeln("RecipientNetType="+NET_INTERNET);
rcptlst_file.writeln("RecipientNetAddr="+header.to);
rcptlst_file.close();
exit(); exit();
} }
/* contribution to mailing list? */ /* contribution to mailing list? */
var contribution=false;
for(r=0;r<rcpt_list.length;r++) { for(r=0;r<rcpt_list.length;r++) {
var l; var l;
for(l=0;l<list_array.length;l++) { for(l=0;l<list_array.length;l++) {
...@@ -258,8 +294,39 @@ mailbase.close(); ...@@ -258,8 +294,39 @@ mailbase.close();
/* End of Main */ /* End of Main */
/* Handle Mailing List Control Messages (e.g. subscribe/unsubscribe) here */ /* Handle Mailing List Control Messages (e.g. subscribe/unsubscribe) here */
function process_control_msg(header, body) function process_control_msg(cmd_list)
{ {
var response = new Array();
response.push("Synchronet ListServer " +REVISION+ " Reponse:");
for(var c in cmd_list) {
var cmd=cmd_list[c];
if(!cmd.length)
continue;
var token=cmd.split(/\s+/);
switch(token[0].toLowerCase()) {
case "lists":
response.push("List of lists:");
for(var l in list_array)
response.push("\t"+list_array[l].name+"\t"+list_array[l].description);
break;
case "end":
return(response);
default:
response.push("!Bad command: " + cmd);
case "help":
response.push("Available commands:");
response.push("\tlists");
response.push("\tsubscribe");
response.push("\tunsubscribe");
response.push("\thelp");
response.push("\tend");
break;
}
}
return(response);
} }
/* Handle Mailing List Contributions here */ /* Handle Mailing List Contributions here */
...@@ -281,6 +348,9 @@ function process_contribution(header, body, list) ...@@ -281,6 +348,9 @@ function process_contribution(header, body, list)
header.id = header["message-id"]; // Convert to Synchronet-compatible header.id = header["message-id"]; // Convert to Synchronet-compatible
if(!user.compare_ars(msgbase.cfg.moderated_ars))
header.attr |= MSG_MODERATED;
if(!msgbase.save_msg(header, body.join('\r\n'))) { if(!msgbase.save_msg(header, body.join('\r\n'))) {
log(LOG_ERR,format("%s !ERROR %s saving message to sub: %s" log(LOG_ERR,format("%s !ERROR %s saving message to sub: %s"
,list.name, msgbase.error, list.sub)); ,list.name, msgbase.error, list.sub));
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment