]> git.ipfire.org Git - thirdparty/mlmmj.git/commitdiff
First iteration of subscription moderation. CVS is hereby broken until further notice
authormmj <none@none>
Thu, 9 Feb 2006 07:06:12 +0000 (18:06 +1100)
committermmj <none@none>
Thu, 9 Feb 2006 07:06:12 +0000 (18:06 +1100)
listtexts/submod-moderator [new file with mode: 0644]
listtexts/submod-requester [new file with mode: 0644]
src/listcontrol.c
src/mlmmj-sub.c

diff --git a/listtexts/submod-moderator b/listtexts/submod-moderator
new file mode 100644 (file)
index 0000000..294eb75
--- /dev/null
@@ -0,0 +1,22 @@
+Subject: Subscription request for $listaddr$
+
+Hi, this is the mlmmj program managing the mailinglist
+
+$listaddr$
+
+There is a subscription request from
+
+$subaddr$
+
+waiting. To approve this request, please send a reply to
+
+$moderateaddr$
+
+Your mailer probably automatically replies to this address, when you hit
+the reply button. If you don't want to approve the request, simply ignore this
+message.
+
+The following subscription moderators have received this mail:
+
+$moderators$
+
diff --git a/listtexts/submod-requester b/listtexts/submod-requester
new file mode 100644 (file)
index 0000000..56d8df8
--- /dev/null
@@ -0,0 +1,9 @@
+Subject: Subscription request waiting for approval
+
+Hi, this is the mlmmj program managing the mailinglist
+
+$listaddr$
+
+This list is configured to have moderated subscription, the request have
+been queued for approval.
+
index e5d2618d9c89db35a1d4265de3f0b41c75905dd9..197de88362d6a52102d6ee5b4809b51840edca3c 100644 (file)
@@ -585,7 +585,6 @@ int listcontrol(struct email_container *fromemails, const char *listdir,
                /* TODO Add accept/reject parameter to moderate */
                moderatefilename = concatstr(3, listdir, "/moderation/", param);
                sendfilename = concatstr(2, moderatefilename, ".sending");
-               myfree(param);
 
                if(stat(moderatefilename, &stbuf) < 0) {
                        myfree(moderatefilename);
@@ -604,6 +603,10 @@ int listcontrol(struct email_container *fromemails, const char *listdir,
 
                log_oper(listdir, OPLOGFNAME, "%s moderated %s",
                                fromemails->emaillist[0], moderatefilename);
+               if(strncmp(param, "subscribe", 9) == 0)
+                       execlp(mlmmjsub, mlmmjsub,
+                                       "-L", listdir,
+                                       "-m", param, (char *)NULL);
                myfree(moderatefilename);
                execlp(mlmmjsend, mlmmjsend,
                                "-L", listdir,
index 088ab0e733bd5eccf5f65348424d82b68ce66cfb..d5d905f1579cbd3fa4a6f591c8c542490bc8e1df 100644 (file)
 #include "statctrl.h"
 #include "prepstdreply.h"
 #include "memory.h"
+#include "ctrlvalues.h"
+
+void moderate_sub(const char *listdir, const char *listaddr,
+               const char *listdelim, const char *subaddr,
+               const char *mlmmjsend, enum subtype typesub)
+{
+       int i, fd;
+       char *a, *queuefilename, *fromaddr, *listname, *listfqdn, *listtext;
+       char *modfilename, *randomstr, *str, *listdelim, *mods;
+       struct strlist *submods;
+       char *maildata[6] = { "subaddr", NULL, "moderateaddr", NULL,
+                               "moderators", NULL };
+
+       submods = ctrlvalues(listdir, "submod");
+
+       /* no subscriber moderation wanted */
+       if(submods == NULL)
+               return;
+
+       /* generate the file in moderation/ */
+       switch(typesub) {
+               default:
+               case SUB_NORMAL:
+                       str = concatstr(4, subaddr, "\n", "SUB_NORMAL", "\n");
+                       break;
+               case SUB_DIGEST:
+                       str = concatstr(4, subaddr, "\n", "SUB_DIGEST", "\n");
+                       break;
+               case SUB_NOMAIL:
+                       str = concatstr(4, subaddr, "\n", "SUB_NOMAIL", "\n");
+                       break;
+       }
+       
+       randomstr = random_str();
+       modfilename = concatstr(3, listdir, "/moderation/subscribe",
+                       randomstr);
+       myfree(randomstr);
+
+       fd = open(modfilename, O_RDWR|O_CREAT|O_EXCL, S_IRUSR|S_IWUSR);
+       while(fd < 0 && errno == EEXIST) {
+               myfree(modfilename);
+               randomstr = random_str();
+               modfilename = concatstr(3, listdir, "/moderation/subscribe",
+                               randomstr);
+               myfree(randomstr);
+               fd = open(modfilename, O_RDWR|O_CREAT|O_EXCL, S_IRUSR|S_IWUSR);
+       }
+       if(fd < 0) {
+               log_error(LOG_ARGS, "could not create %s", modfilename);
+               log_error(LOG_ARGS, "ignoring request: %s", str);
+               myfree(modfilename);
+               myfree(str);
+               exit(EXIT_FAILURE);
+       }
+       if(writen(fd, str, strlen(str)) < 0) {
+               log_error(LOG_ARGS, "could not write to %s", modfilename);
+               log_error(LOG_ARGS, "ignoring request: %s", str);
+               myfree(modfilename);
+               myfree(str);
+               exit(EXIT_FAILURE);
+       }
+       
+       close(fd);
+       
+       myfree(str);
+
+       /* check to see if there's adresses in the submod control file */
+       for(i = 0; i < submods->count; i++)
+               a = strchr(submods->strs[i], '@');
+
+       mods = concatstr(2, listdir, "/control/submod");
+
+       /* no addresses in submod control file, use owner */
+       if(a == NULL) {
+               /* free the submods struct from above */
+               for(i = 0; i < submods->count; i++)
+                       myfree(submods->strs[i]);
+               myfree(submods->strs);
+               mods = concatstr(2, listdir, "/control/owner");
+       }
+
+       /* send mail to requester that the list is submod'ed */
+
+       /* send mail to moderators about request pending */
+       listdelim = getlistdelim(listdir);
+       listfqdn = genlistfqdn(listaddr);
+       listname = genlistname(listaddr);
+
+       from = concatstr(4, listname, listdelim, "owner@", listfqdn);
+       to = concatstr(3, listname, "-moderators@", listfqdn);
+       replyto = concatstr(6, listname, listdelim, "moderate-", modfilename,
+                       "@", listfqdn);
+       for(i = 0; i < submods->count; i++) {
+               str = moderators;
+               moderators = concatstr(3, moderators, submods->strs[i], "\n");
+               myfree(str);
+       }
+
+       maildata[1] = subaddr;
+       maildata[3] = replyto;
+       maildata[5] = moderators;
+
+       queuefilename = prepstdreply(listdir, "submod-moderator",
+                               "$listowner$", to, replyto, 3, maildata);
+                       
+       myfree(listdelim);
+       myfree(listname);
+       myfree(listfqdn);
+
+       if((fd = open(queuefilename, O_RDONLY) < 0)) {
+               log_error(LOG_ARGS, "Could not open '%s'", queuefilename);
+               log_error(LOG_ARGS, "Request in %s not served", modfilename);
+               myfree(queuefilename);
+               
+       execlp(mlmmjsend, mlmmjsend,
+                               "-a",
+                               "-l", "4",
+                               "-L", listdir,
+                               "-s", mods,
+                               "-F", from,
+                               "-R", replyto,
+                               "-m", queuefilename, (char *)NULL);
+
+}
 
 void confirm_sub(const char *listdir, const char *listaddr,
                const char *listdelim, const char *subaddr,