changeset 705:79dd917e0150

ifmodsendonlymodmoderate
author mmj
date Mon, 27 Jul 2009 21:55:27 +1000
parents 43a224d79133
children 52189a450b0c
files TUNABLES src/mlmmj-process.c
diffstat 2 files changed, 38 insertions(+), 8 deletions(-) [+]
line wrap: on
line diff
--- a/TUNABLES	Wed Jul 08 03:52:30 2009 +1000
+++ b/TUNABLES	Mon Jul 27 21:55:27 2009 +1000
@@ -203,3 +203,11 @@
    If this is set to something@example.org, the bounce address (Return-Path:)
    will be fixed to something+listname-bounces-and-so-on@example.org
    in case you need to disable automatic bounce handling.
+
+ · ifmodsendonlymodmoderate	(boolean)
+
+   If this file is present, then mlmmj in case of moderation checks the
+   envelope from, to see if the sender is a moderator, and in that case
+   only send the moderation mails to that address. In practice this means that
+   a moderator sending mail to the list wont bother all the other moderators
+   with his mail.
--- a/src/mlmmj-process.c	Wed Jul 08 03:52:30 2009 +1000
+++ b/src/mlmmj-process.c	Mon Jul 27 21:55:27 2009 +1000
@@ -70,13 +70,13 @@
 
 
 void newmoderated(const char *listdir, const char *mailfilename,
-		  const char *mlmmjsend)
+		  const char *mlmmjsend, const char *efromsender)
 {
 	char *from, *listfqdn, *listname, *moderators = NULL;
 	char *buf, *replyto, *listaddr = getlistaddr(listdir), *listdelim;
-	char *queuefilename = NULL, *moderatorsfilename;
+	char *queuefilename = NULL, *moderatorsfilename, *efromismod = NULL;
 	char *mailbasename = mybasename(mailfilename), *tmp, *to;
-	int moderatorsfd;
+	int moderatorsfd, foundaddr = 0;
 	char *maildata[4] = { "moderateaddr", NULL, "moderators", NULL };
 #if 0
 	printf("mailfilename = [%s], mailbasename = [%s]\n", mailfilename,
@@ -93,13 +93,23 @@
 	}
 	myfree(moderatorsfilename);
 
+	if(statctrl(listdir, "ifmodsendonlymodmoderate"))
+		efromismod = concatstr(2, efromsender, "\n");
+
 	while((buf = mygetline(moderatorsfd))) {
+		if(efromismod && strcmp(buf, efromismod) == 0)
+			foundaddr = 1;
 		tmp = moderators;
 		moderators = concatstr(2, moderators, buf);
 		myfree(buf);
 		myfree(tmp);
 	}
 
+	if(!foundaddr) {
+		myfree(efromismod);
+		efromismod = NULL;
+	}
+
 	close(moderatorsfd);
 
 	listdelim = getlistdelim(listdir);
@@ -107,6 +117,10 @@
 			    "@", listfqdn);
 
 	maildata[1] = replyto;
+	if(efromismod) {
+		myfree(moderators);
+		maildata[3] = efromismod;
+	} else
 	maildata[3] = moderators;
 
 	from = concatstr(4, listname, listdelim, "owner@", listfqdn);
@@ -119,6 +133,14 @@
 	queuefilename = prepstdreply(listdir, "moderation", "$listowner$",
 				     to, replyto, 2, maildata, NULL, mailfilename);
 
+	if(efromismod)
+		execlp(mlmmjsend, mlmmjsend,
+				"-l", "1",
+				"-L", listdir,
+				"-F", from,
+				"-m", queuefilename,
+				"-T", efromsender, (char *)NULL);
+	else
 	execlp(mlmmjsend, mlmmjsend,
 				"-l", "2",
 				"-L", listdir,
@@ -912,7 +934,7 @@
 			exit(EXIT_FAILURE);
 		}
 		myfree(donemailname);
-		newmoderated(listdir, mqueuename, mlmmjsend);
+		newmoderated(listdir, mqueuename, mlmmjsend, efrom);
 		return EXIT_SUCCESS;
 	}