mlmmj

changeset 926f184eec44

Add a $subject$ substitution for list texts
author Ben Schmidt
date Mon, 20 Sep 2010 02:25:54 +1000
parents c2ffbdcf3be5
children 5edfa9eef6c7
files ChangeLog README.listtexts src/mlmmj-process.c
diffstat 3 files changed, 40 insertions(+), 14 deletions(-) [+]
line diff
     1.1 --- a/ChangeLog	Mon Sep 20 02:07:42 2010 +1000
     1.2 +++ b/ChangeLog	Mon Sep 20 02:25:54 2010 +1000
     1.3 @@ -1,3 +1,4 @@
     1.4 + o Add a $subject$ substitution for list texts
     1.5   o Changes to how $originalmail$ works -- existing installations will change
     1.6     behaviour due to this; prepending a space to the lines currently containing
     1.7     $originalmail$ in the listtexts will generally retain current behaviour
     2.1 --- a/README.listtexts	Mon Sep 20 02:07:42 2010 +1000
     2.2 +++ b/README.listtexts	Mon Sep 20 02:25:54 2010 +1000
     2.3 @@ -237,13 +237,19 @@
     2.4    number like 1000000000.
     2.5  
     2.6  - $posteraddr$
     2.7 -  (available only in subonlypost)
     2.8 +  (available only in access, notintocc, moderation, moderation-poster and
     2.9 +  subonlypost)
    2.10    the from address of the message that was received as determined by Mlmmj
    2.11  
    2.12  - $subaddr$
    2.13    (available only in submod-moderator and [un]sub-confirm[-digest|-nomail])
    2.14    the address requested to be (un-)subscribed
    2.15  
    2.16 +- $subject$
    2.17 +  (available only in access, notintocc, moderation, moderation-poster and
    2.18 +  subonlypost)
    2.19 +  the subject line of the message in question
    2.20 +
    2.21  - \uNNNN
    2.22    (NNNN are hex digits)
    2.23    a Unicode character
     3.1 --- a/src/mlmmj-process.c	Mon Sep 20 02:07:42 2010 +1000
     3.2 +++ b/src/mlmmj-process.c	Mon Sep 20 02:25:54 2010 +1000
     3.3 @@ -52,6 +52,7 @@
     3.4  #include "memory.h"
     3.5  #include "log_oper.h"
     3.6  #include "chomp.h"
     3.7 +#include "unistr.h"
     3.8  
     3.9  enum action {
    3.10  	ALLOW,
    3.11 @@ -71,14 +72,16 @@
    3.12  
    3.13  
    3.14  void newmoderated(const char *listdir, const char *mailfilename,
    3.15 -		  const char *mlmmjsend, const char *efromsender)
    3.16 +		  const char *mlmmjsend, const char *efromsender,
    3.17 +		  size_t tokencount, char **data)
    3.18  {
    3.19 +	size_t i;
    3.20  	char *from, *listfqdn, *listname, *moderators = NULL;
    3.21  	char *buf, *replyto, *listaddr = getlistaddr(listdir), *listdelim;
    3.22  	char *queuefilename = NULL, *moderatorsfilename, *efromismod = NULL;
    3.23  	char *mailbasename = mybasename(mailfilename), *tmp, *to;
    3.24  	int moderatorsfd, foundaddr = 0, notifymod = 0, status;
    3.25 -	char *maildata[4] = { "moderateaddr", NULL, "moderators", NULL };
    3.26 +	char *maildata[10] = { "moderateaddr", NULL, "moderators", NULL };
    3.27  	pid_t childpid, pid;
    3.28  #if 0
    3.29  	printf("mailfilename = [%s], mailbasename = [%s]\n", mailfilename,
    3.30 @@ -87,6 +90,13 @@
    3.31  	listfqdn = genlistfqdn(listaddr);
    3.32  	listname = genlistname(listaddr);
    3.33  
    3.34 +	MY_ASSERT(tokencount<=3)
    3.35 +	for (i=0; i<tokencount; i++) {
    3.36 +		maildata[4+2*i] = data[2*i];
    3.37 +		maildata[5+2*i] = data[1+2*i];
    3.38 +	}
    3.39 +	tokencount += 2;
    3.40 +
    3.41  	moderatorsfilename = concatstr(2, listdir, "/control/moderators");
    3.42  	if((moderatorsfd = open(moderatorsfilename, O_RDONLY)) < 0) {
    3.43  		log_error(LOG_ARGS, "Could not open '%s'", moderatorsfilename);
    3.44 @@ -133,7 +143,7 @@
    3.45  	myfree(listfqdn);
    3.46  
    3.47  	queuefilename = prepstdreply(listdir, "moderation", "$listowner$",
    3.48 -				     to, replyto, 2, maildata,
    3.49 +				     to, replyto, tokencount, maildata,
    3.50  				     mailfilename);
    3.51  
    3.52  	/* we might need to exec more than one mlmmj-send */
    3.53 @@ -176,7 +186,7 @@
    3.54  
    3.55  	queuefilename = prepstdreply(listdir, "moderation-poster",
    3.56  				     "$listowner$", efromsender,
    3.57 -				     NULL, 1, maildata+2, mailfilename);
    3.58 +				     NULL, tokencount-1, maildata+2, mailfilename);
    3.59  
    3.60  	execlp(mlmmjsend, mlmmjsend,
    3.61  			"-l", "1",
    3.62 @@ -385,7 +395,8 @@
    3.63  	char *listfqdn, *listname, *fromaddr;
    3.64  	char *queuefilename, *recipextra = NULL, *owner = NULL;
    3.65  	char *maxmailsizestr;
    3.66 -	char *maildata[4] = { "posteraddr", NULL, "maxmailsize", NULL };
    3.67 +	char *maildata[6] = { "subject", NULL,
    3.68 +		"posteraddr", NULL, "maxmailsize", NULL };
    3.69  	char *envstr, *efrom;
    3.70  	struct stat st;
    3.71  	uid_t uid;
    3.72 @@ -404,6 +415,7 @@
    3.73  		{ "Cc:", 0, NULL },
    3.74  		{ "Return-Path:", 0, NULL },
    3.75  		{ "Delivered-To:", 0, NULL },
    3.76 +		{ "Subject:", 0, NULL },
    3.77  		{ NULL, 0, NULL }
    3.78  	};
    3.79  
    3.80 @@ -538,6 +550,8 @@
    3.81  	for(i = 0; i < readhdrs[0].valuecount; i++) {
    3.82  		find_email_adr(readhdrs[0].values[i], &fromemails);
    3.83  	}
    3.84 +	if (fromemails.emailcount)
    3.85 +		maildata[3] = fromemails.emaillist[0];
    3.86  
    3.87  	/* To: addresses */
    3.88  	for(i = 0; i < readhdrs[1].valuecount; i++) {
    3.89 @@ -559,6 +573,12 @@
    3.90  		find_email_adr(readhdrs[4].values[i], &dtemails);
    3.91  	}
    3.92  
    3.93 +	/* Subject: */
    3.94 +	if (readhdrs[5].valuecount)
    3.95 +		maildata[1] = unistr_header_to_utf8(readhdrs[5].values[0]);
    3.96 +	if (!maildata[1])
    3.97 +		maildata[1] = mystrdup("");
    3.98 +
    3.99  	/* envelope from */
   3.100  	if((envstr = getenv("SENDER")) != NULL) {
   3.101  		/* qmail, postfix, exim */
   3.102 @@ -635,7 +655,7 @@
   3.103  			close(rawmailfd);
   3.104  			close(donemailfd);
   3.105  			unlink(mailfile);
   3.106 -			log_oper(listdir, OPLOGFNAME, "mlmmj-recieve: sending"
   3.107 +			log_oper(listdir, OPLOGFNAME, "mlmmj-process: sending"
   3.108  					" mail from %s to owner",
   3.109  					efrom);
   3.110  			execlp(mlmmjsend, mlmmjsend,
   3.111 @@ -692,11 +712,11 @@
   3.112  			listfqdn = genlistfqdn(listaddr);
   3.113  			fromaddr = concatstr(4, listname, listdelim,
   3.114  					"bounces-help@", listfqdn);
   3.115 -			maildata[3] = maxmailsizestr;
   3.116 +			maildata[5] = maxmailsizestr;
   3.117  			queuefilename = prepstdreply(listdir,
   3.118  					"maxmailsize", "$listowner$",
   3.119  					fromemails.emaillist[0],
   3.120 -					NULL, 1, maildata+2, donemailname);
   3.121 +					NULL, 1, maildata+4, donemailname);
   3.122  			MY_ASSERT(queuefilename)
   3.123  			myfree(listdelim);
   3.124  			myfree(listname);
   3.125 @@ -811,7 +831,7 @@
   3.126  				     listfqdn);
   3.127  		queuefilename = prepstdreply(listdir, "notintocc",
   3.128  					"$listowner$", fromemails.emaillist[0],
   3.129 -					     NULL, 0, NULL, donemailname);
   3.130 +					     NULL, 2, maildata, donemailname);
   3.131  		MY_ASSERT(queuefilename)
   3.132  		myfree(listdelim);
   3.133  		myfree(listname);
   3.134 @@ -867,12 +887,11 @@
   3.135  			listdelim = getlistdelim(listdir);
   3.136  			listname = genlistname(listaddr);
   3.137  			listfqdn = genlistfqdn(listaddr);
   3.138 -			maildata[1] = fromemails.emaillist[0];
   3.139  			fromaddr = concatstr(4, listname, listdelim,
   3.140  					"bounces-help@", listfqdn);
   3.141  			queuefilename = prepstdreply(listdir, "subonlypost",
   3.142  					"$listowner$", fromemails.emaillist[0],
   3.143 -						     NULL, 1, maildata, donemailname);
   3.144 +						     NULL, 2, maildata, donemailname);
   3.145  			MY_ASSERT(queuefilename)
   3.146  			myfree(listaddr);
   3.147  			myfree(listdelim);
   3.148 @@ -927,7 +946,7 @@
   3.149  			queuefilename = prepstdreply(listdir, "access",
   3.150  							"$listowner$",
   3.151  							fromemails.emaillist[0],
   3.152 -						     NULL, 0, NULL, donemailname);
   3.153 +						     NULL, 2, maildata, donemailname);
   3.154  			MY_ASSERT(queuefilename)
   3.155  			myfree(listaddr);
   3.156  			myfree(listdelim);
   3.157 @@ -1004,7 +1023,7 @@
   3.158  			fsync(omitfd);
   3.159  			close(omitfd);
   3.160  		}
   3.161 -		newmoderated(listdir, mqueuename, mlmmjsend, efrom);
   3.162 +		newmoderated(listdir, mqueuename, mlmmjsend, efrom, 2, maildata);
   3.163  		return EXIT_SUCCESS;
   3.164  	}
   3.165