# HG changeset patch # User Ben Schmidt # Date 1280498685 -36000 # Node ID d78eb18576b05215b83f756fec7fd8c272310d29 # Parent e5286b45f9ca495962c3ad2aa7e00eb0bcec9192 Added feature to notify users when their posts are moderated diff -r e5286b45f9ca -r d78eb18576b0 ChangeLog --- a/ChangeLog Sat Jul 31 00:00:31 2010 +1000 +++ b/ChangeLog Sat Jul 31 00:04:45 2010 +1000 @@ -1,3 +1,4 @@ + o Added feature to notify users when their posts are moderated o Fixed documentation regarding silent subscription, and added ability to silently subscribe o Added notmetoo feature where posts are not mirrored to their senders diff -r e5286b45f9ca -r d78eb18576b0 TUNABLES --- a/TUNABLES Sat Jul 31 00:00:31 2010 +1000 +++ b/TUNABLES Sat Jul 31 00:04:45 2010 +1000 @@ -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 e5286b45f9ca -r d78eb18576b0 contrib/web/perl-admin/conf/tunables.pl --- a/contrib/web/perl-admin/conf/tunables.pl Sat Jul 31 00:00:31 2010 +1000 +++ b/contrib/web/perl-admin/conf/tunables.pl Sat Jul 31 00:04:45 2010 +1000 @@ -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 e5286b45f9ca -r d78eb18576b0 contrib/web/php-admin/conf/tunables.pl --- a/contrib/web/php-admin/conf/tunables.pl Sat Jul 31 00:00:31 2010 +1000 +++ b/contrib/web/php-admin/conf/tunables.pl Sat Jul 31 00:04:45 2010 +1000 @@ -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 e5286b45f9ca -r d78eb18576b0 listtexts/en/moderation-poster --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/listtexts/en/moderation-poster Sat Jul 31 00:04:45 2010 +1000 @@ -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 e5286b45f9ca -r d78eb18576b0 src/mlmmj-process.c --- a/src/mlmmj-process.c Sat Jul 31 00:00:31 2010 +1000 +++ b/src/mlmmj-process.c Sat Jul 31 00:04:45 2010 +1000 @@ -77,8 +77,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); @@ -132,8 +133,26 @@ myfree(listfqdn); queuefilename = prepstdreply(listdir, "moderation", "$listowner$", - to, replyto, 2, maildata, NULL, mailfilename); + to, replyto, 2, maildata, NULL, + mailfilename); + + /* 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", @@ -147,9 +166,26 @@ "-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); }