MLMMJ Mailing List Manager
 help / color / mirror / Atom feed
From: Ben Schmidt <mail_ben_schmidt@yahoo.com.au>
To: mlmmj@mlmmj.org
Subject: PATCH: Notify moderation
Date: Tue, 26 Jan 2010 12:13:38 +0000	[thread overview]
Message-ID: <4B5EDC72.7040104@yahoo.com.au> (raw)

[-- Attachment #1: Type: text/plain, Size: 697 bytes --]

This patch allows posters to be sent notification when their posts are held for 
moderation. Requires new listtext.

Tests fine for me (as have all the patches I have sent, though I neglected to 
mention once or twice).

Could this be included in mlmmj?

I realise I'm sending quite a few patches for consideration here! I believe these 
are all useful additions, though. They are features that are present in other 
mailing list programs, and which I need and use.

This will be all for a little while, too. The few other things I'm interested in 
are lower priority. I'm keen to have these patches I've already sent included in 
mlmmj (after discussion and modification as appropriate)!

Ben.



[-- Warning: decoded text below may be mangled, UTF-8 assumed --]
[-- Attachment #2: mlmmj-notifymod.patch --]
[-- Type: text/x-patch; name="mlmmj-notifymod.patch", Size: 5002 bytes --]

diff -r 2918436fa450 TUNABLES
--- a/TUNABLES	Tue Jan 26 22:19:57 2010 +1100
+++ b/TUNABLES	Tue Jan 26 22:45:06 2010 +1100
@@ -103,6 +103,11 @@
    If this file is present, the owner(s) will get a mail with the address of
    someone sub/unsubscribing to a mailinglist.
 
+ ��� notifymod			(boolean)
+
+   If this file is present, the poster (based on the envelope from) will
+   get a mail when their post is being moderation.
+
  ��� digestinterval		(normal)
 
    This file specifies how many seconds will pass before the next digest is
diff -r 2918436fa450 contrib/web/perl-admin/conf/tunables.pl
--- a/contrib/web/perl-admin/conf/tunables.pl	Tue Jan 26 22:19:57 2010 +1100
+++ b/contrib/web/perl-admin/conf/tunables.pl	Tue Jan 26 22:45:06 2010 +1100
@@ -100,6 +100,11 @@
 			  "Notify subscribers",
 			  "If this option is set, the owner(s) will get a mail with the address of someone sub/unsubscribing to a mailinglist.");
 
+mlmmj_boolean("notifymod",
+			  "Notify moderation",
+			  "If this option is set, the poster (based on the envelope from) will ".
+			  "get a mail when their post is being moderation.");
+
 mlmmj_string("digestinterval",
 			 "Digest interval",
 			 "This option specifies how many seconds will pass before the ".
diff -r 2918436fa450 contrib/web/php-admin/conf/tunables.pl
--- a/contrib/web/php-admin/conf/tunables.pl	Tue Jan 26 22:19:57 2010 +1100
+++ b/contrib/web/php-admin/conf/tunables.pl	Tue Jan 26 22:45:06 2010 +1100
@@ -100,6 +100,11 @@
 			  "Notify subscribers",
 			  "If this option is set, the owner(s) will get a mail with the address of someone sub/unsubscribing to a mailinglist.");
 
+mlmmj_boolean("notifymod",
+			  "Notify moderation",
+			  "If this option is set, the poster (based on the envelope from) will ".
+			  "get a mail when their post is being moderation.");
+
 mlmmj_string("digestinterval",
 			 "Digest interval",
 			 "This option specifies how many seconds will pass before the ".
diff -r 2918436fa450 listtexts/en/moderation-poster
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/listtexts/en/moderation-poster	Tue Jan 26 22:45:06 2010 +1100
@@ -0,0 +1,11 @@
+Subject: Post waiting for approval
+
+Hi, this is the mlmmj program managing the mailinglist
+
+$listaddr$
+
+This list is configured to have moderated posts, the post has been queued
+for approval.
+
+--- Below this line are the first 100 lines of the message up for moderation --->
+$originalmail$
diff -r 2918436fa450 src/mlmmj-process.c
--- a/src/mlmmj-process.c	Tue Jan 26 22:19:57 2010 +1100
+++ b/src/mlmmj-process.c	Tue Jan 26 22:45:06 2010 +1100
@@ -76,8 +76,9 @@
 	char *buf, *replyto, *listaddr = getlistaddr(listdir), *listdelim;
 	char *queuefilename = NULL, *moderatorsfilename, *efromismod = NULL;
 	char *mailbasename = mybasename(mailfilename), *tmp, *to;
-	int moderatorsfd, foundaddr = 0;
+	int moderatorsfd, foundaddr = 0, notifymod = 0, status;
 	char *maildata[4] = { "moderateaddr", NULL, "moderators", NULL };
+	pid_t childpid, pid;
 #if 0
 	printf("mailfilename = [%s], mailbasename = [%s]\n", mailfilename,
 			                                     mailbasename);
@@ -131,24 +132,59 @@
 	myfree(listfqdn);
 
 	queuefilename = prepstdreply(listdir, "moderation", "$listowner$",
-				     to, replyto, 2, maildata, NULL, mailfilename);
+				     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,
-				"-F", from,
-				"-m", queuefilename, (char *)NULL);
+	/* we might need to exec more than one mlmmj-send */
+	
+	notifymod = !efromismod && statctrl(listdir,"notifymod");
+	
+	if (notifymod) {
+		childpid = fork();
+		if(childpid < 0)
+			log_error(LOG_ARGS, "Could not fork; poster not notified");
+	} else
+		childpid = -1;
+
+	if(childpid != 0) {
+		if(childpid > 0) {
+			do /* Parent waits for the child */
+				pid = waitpid(childpid, &status, 0);
+			while(pid == -1 && errno == EINTR);
+		}
+		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,
+					"-F", from,
+					"-m", queuefilename, (char *)NULL);
+		log_error(LOG_ARGS, "execlp() of '%s' failed", mlmmjsend);
+		exit(EXIT_FAILURE);
+	}
+
+	myfree(queuefilename);
+
+	/* send mail to poster that the list is moderated */
+
+	queuefilename = prepstdreply(listdir, "moderation-poster",
+				     "$listowner$", efromsender,
+				     NULL, 1, maildata+2, NULL, mailfilename);
+
+	execlp(mlmmjsend, mlmmjsend,
+			"-l", "1",
+			"-L", listdir,
+			"-F", from,
+			"-m", queuefilename,
+			"-T", efromsender, (char *)NULL);
 
 	log_error(LOG_ARGS, "execlp() of '%s' failed", mlmmjsend);
-
 	exit(EXIT_FAILURE);
 }
 

             reply	other threads:[~2010-01-26 12:13 UTC|newest]

Thread overview: 3+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2010-01-26 12:13 Ben Schmidt [this message]
2010-01-26 12:17 ` PATCH: Notify moderation Mads Martin Jørgensen
2010-03-09 22:34 ` [mlmmj] " Ben Schmidt

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=4B5EDC72.7040104@yahoo.com.au \
    --to=mail_ben_schmidt@yahoo.com.au \
    --cc=mlmmj@mlmmj.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox