]> git.ipfire.org Git - thirdparty/mlmmj.git/commitdiff
subscribtion: reduce confusion
authorBaptiste Daroussin <bapt@FreeBSD.org>
Wed, 12 Apr 2023 07:56:05 +0000 (09:56 +0200)
committerBaptiste Daroussin <bapt@FreeBSD.org>
Wed, 12 Apr 2023 08:12:57 +0000 (10:12 +0200)
Reduce confusion by renaming variables and function to more obvious name

include/subscriberfuncs.h
src/mlmmj-sub.c
src/mlmmj-unsub.c
src/subscriberfuncs.c
tests/mlmmj.c

index fa3ae21771570fdcdc7683784eee1003f32b7d05..0c4787154770f46bb869d3f8a6a94b69695ac66f 100644 (file)
@@ -34,4 +34,4 @@ void notify_sub(struct ml *ml, const char *subaddr, enum subtype typesub,
 void generate_subscription(struct ml *ml, const char *subaddr, enum subtype typesub, bool sub);
 void generate_subconfirm(struct ml *ml, const char *subaddr, enum subtype typesub,
     enum subreason reasonsub, bool sub);
-void confirm_sub(struct ml *ml, const char *subaddr, enum subtype typesub, enum subreason reasonsub, bool sub);
+void send_confirmation_mail(struct ml *ml, const char *subaddr, enum subtype typesub, enum subreason reasonsub, bool sub);
index ae139c77f53160c6c95345994735c7b36f4f000d..dd6d86ca9fce10ae30eddb9090a1a47eac7f6145 100644 (file)
@@ -319,7 +319,8 @@ int main(int argc, char **argv)
 {
        char *mlmmjsend, *bindir;
        char *address = NULL, *modstr = NULL;
-       int opt, subconfirm = 0, confirmsub = 0, notifysub;
+       bool send_welcome_mail = false;
+       int opt, subconfirm = 0, notifysub;
        int changeuid = 1, digest = 0, nomail = 0, both = 0;
        int nogensubscribed = 0;
        int force = 0, quiet = 0;
@@ -351,7 +352,7 @@ int main(int argc, char **argv)
                        both = 1;
                        break;
                case 'c':
-                       confirmsub = 1;
+                       send_welcome_mail = true;
                        break;
                case 'C':
                        subconfirm = 1;
@@ -490,8 +491,8 @@ int main(int argc, char **argv)
                subscribe_type(ml.fd, address, typesub);
        }
 
-       if(confirmsub)
-               confirm_sub(&ml, address, typesub, reasonsub, true);
+       if(send_welcome_mail)
+               send_confirmation_mail(&ml, address, typesub, reasonsub, true);
 
        notifysub = !quiet && reasonsub != SUB_SWITCH &&
                        statctrl(ml.ctrlfd, "notifysub");
index e2f6aa6c5b47d1f636960ede6c146ee8dc821e75..3c14106e348e22ffa1bbaa6f66fc8e86775cda86 100644 (file)
@@ -71,9 +71,10 @@ int main(int argc, char **argv)
 {
        int opt;
        int normal = 0, digest = 0, nomail = 0, subbed;
-       int confirmunsub = 0, unsubconfirm = 0, notifysub = 0;
+       int unsubconfirm = 0, notifysub = 0;
        int changeuid = 1, quiet = 0;
-       int nogennotsubscribed = 0;
+       bool inform_not_subscribed = true;
+       bool send_goodbye_mail = false;
        char *address = NULL;
        const char *subdir;
        enum subtype typesub = SUB_ALL;
@@ -97,7 +98,7 @@ int main(int argc, char **argv)
                        address = optarg;
                        break;
                case 'c':
-                       confirmunsub = 1;
+                       send_goodbye_mail = true;
                        break;
                case 'C':
                        unsubconfirm = 1;
@@ -124,7 +125,7 @@ int main(int argc, char **argv)
                        reasonsub = SUB_CONFIRM;
                        break;
                case 's':
-                       nogennotsubscribed = 1;
+                       inform_not_subscribed = false;
                        break;
                case 'U':
                        changeuid = 0;
@@ -154,7 +155,7 @@ int main(int argc, char **argv)
                typesub = SUB_NORMAL;
 
 
-       if(confirmunsub && unsubconfirm) {
+       if(send_goodbye_mail && unsubconfirm) {
                errx(EXIT_FAILURE, "Cannot specify both -C and -c\n"
                    "%s -h for help", argv[0]);
        }
@@ -193,7 +194,7 @@ int main(int argc, char **argv)
 
        if(!subbed) {
                /* Address is not subscribed */
-               if(!nogennotsubscribed)
+               if(inform_not_subscribed)
                        generate_subscription(&ml, address, typesub, false);
                exit(EXIT_SUCCESS);
        }
@@ -203,8 +204,8 @@ int main(int argc, char **argv)
 
        unsubscribe(ml.fd, address, typesub);
 
-       if(confirmunsub)
-               confirm_sub(&ml, address, typesub, reasonsub, false);
+       if(send_goodbye_mail)
+               send_confirmation_mail(&ml, address, typesub, reasonsub, false);
 
        notifysub = !quiet && statctrl(ml.ctrlfd, "notifysub");
 
index 2459eb0906d55df260cfc0ac296fc0a3d6895584..50dd7b72b90505e2d9c62fd7bb0bbd9f0e3f0979 100644 (file)
@@ -318,7 +318,7 @@ generate_subconfirm(struct ml *ml, const char *subaddr, enum subtype typesub,
 }
 
 void
-confirm_sub(struct ml *ml, const char *subaddr, enum subtype typesub,
+send_confirmation_mail(struct ml *ml, const char *subaddr, enum subtype typesub,
     enum subreason reasonsub, bool sub)
 {
        text *txt;
index a8e4a61db0866558bf24b307d7101c797a94cbde..c188ae44a884a613a7f7935696937e1dcbac5596 100644 (file)
@@ -143,7 +143,7 @@ ATF_TC_WITHOUT_HEAD(save_queue);
 ATF_TC_WITHOUT_HEAD(send_single_mail);
 ATF_TC_WITHOUT_HEAD(generate_subscription);
 ATF_TC_WITHOUT_HEAD(generate_subconfirm);
-ATF_TC_WITHOUT_HEAD(confirm_sub);
+ATF_TC_WITHOUT_HEAD(send_confirmation_mail);
 ATF_TC_WITHOUT_HEAD(listcontrol);
 ATF_TC_WITHOUT_HEAD(send_help);
 ATF_TC_WITHOUT_HEAD(requeuemail);
@@ -2325,7 +2325,7 @@ ATF_TC_BODY(generate_subconfirm, tc)
        }
 }
 
-ATF_TC_BODY(confirm_sub, tc)
+ATF_TC_BODY(send_confirmation_mail, tc)
 {
        char *dir;
        const char *path;
@@ -2345,7 +2345,7 @@ ATF_TC_BODY(confirm_sub, tc)
        ATF_REQUIRE(socketpair(AF_UNIX, SOCK_STREAM, 0, smtppipe) >= 0);
        pid_t p2 = single_mail_reception(smtppipe[1]);
        atf_utils_readline(smtppipe[0]);
-       confirm_sub(&ml, "test@plop", SUB_NORMAL, SUB_ADMIN, true);
+       send_confirmation_mail(&ml, "test@plop", SUB_NORMAL, SUB_ADMIN, true);
        atf_utils_wait(p2, 0, "save:mailout.txt", "");
        path = "mailout.txt";
        if (!atf_utils_grep_file(".*An administrator has subscribed you to the normal version of the list.*", path)) {
@@ -2359,7 +2359,7 @@ ATF_TC_BODY(confirm_sub, tc)
 
        p2 = single_mail_reception(smtppipe[1]);
        atf_utils_readline(smtppipe[0]);
-       confirm_sub(&ml, "test@plop", SUB_DIGEST, SUB_ADMIN, true);
+       send_confirmation_mail(&ml, "test@plop", SUB_DIGEST, SUB_ADMIN, true);
        atf_utils_wait(p2, 0, "save:mailout.txt", "");
        if (!atf_utils_grep_file(".*An administrator has subscribed you to the digest version of the list.*", path)) {
                atf_utils_cat_file(path, "");
@@ -2372,7 +2372,7 @@ ATF_TC_BODY(confirm_sub, tc)
 
        p2 = single_mail_reception(smtppipe[1]);
        atf_utils_readline(smtppipe[0]);
-       confirm_sub(&ml, "test@plop", SUB_NOMAIL, SUB_CONFIRM, true);
+       send_confirmation_mail(&ml, "test@plop", SUB_NOMAIL, SUB_CONFIRM, true);
        atf_utils_wait(p2, 0, "save:mailout.txt", "");
        if (!atf_utils_grep_file(".*Thank you for confirming your subscription. You have now been added to the.*", path)) {
                atf_utils_cat_file(path, "");
@@ -2385,7 +2385,7 @@ ATF_TC_BODY(confirm_sub, tc)
 
        p2 = single_mail_reception(smtppipe[1]);
        atf_utils_readline(smtppipe[0]);
-       confirm_sub(&ml, "test@plop", SUB_BOTH, SUB_REQUEST, true);
+       send_confirmation_mail(&ml, "test@plop", SUB_BOTH, SUB_REQUEST, true);
        atf_utils_wait(p2, 0, "save:mailout.txt", "");
        if (!atf_utils_grep_file(".*Thank you for your request to join us. You have now been added to the.*", path)) {
                atf_utils_cat_file(path, "");
@@ -2398,7 +2398,7 @@ ATF_TC_BODY(confirm_sub, tc)
 
        p2 = single_mail_reception(smtppipe[1]);
        atf_utils_readline(smtppipe[0]);
-       confirm_sub(&ml, "test@plop", SUB_NORMAL, SUB_ADMIN, false);
+       send_confirmation_mail(&ml, "test@plop", SUB_NORMAL, SUB_ADMIN, false);
        atf_utils_wait(p2, 0, "save:mailout.txt", "");
        if (!atf_utils_grep_file(".*An administrator has removed you from the list.*", path)) {
                atf_utils_cat_file(path, "");
@@ -2407,7 +2407,7 @@ ATF_TC_BODY(confirm_sub, tc)
 
        p2 = single_mail_reception(smtppipe[1]);
        atf_utils_readline(smtppipe[0]);
-       confirm_sub(&ml, "test@plop", SUB_DIGEST, SUB_ADMIN, false);
+       send_confirmation_mail(&ml, "test@plop", SUB_DIGEST, SUB_ADMIN, false);
        atf_utils_wait(p2, 0, "save:mailout.txt", "");
        if (!atf_utils_grep_file(".*An administrator has removed you from the list.*", path)) {
                atf_utils_cat_file(path, "");
@@ -2416,7 +2416,7 @@ ATF_TC_BODY(confirm_sub, tc)
 
        p2 = single_mail_reception(smtppipe[1]);
        atf_utils_readline(smtppipe[0]);
-       confirm_sub(&ml, "test@plop", SUB_NOMAIL, SUB_CONFIRM, false);
+       send_confirmation_mail(&ml, "test@plop", SUB_NOMAIL, SUB_CONFIRM, false);
        atf_utils_wait(p2, 0, "save:mailout.txt", "");
        if (!atf_utils_grep_file(".*Thank you for confirming your unsubscribe. You have now been removed from.*", path)) {
                atf_utils_cat_file(path, "");
@@ -2425,7 +2425,7 @@ ATF_TC_BODY(confirm_sub, tc)
 
        p2 = single_mail_reception(smtppipe[1]);
        atf_utils_readline(smtppipe[0]);
-       confirm_sub(&ml, "test@plop", SUB_BOTH, SUB_REQUEST, false);
+       send_confirmation_mail(&ml, "test@plop", SUB_BOTH, SUB_REQUEST, false);
        atf_utils_wait(p2, 0, "save:mailout.txt", "");
        if (!atf_utils_grep_file(".*You have now been removed from the list.*", path)) {
                atf_utils_cat_file(path, "");
@@ -2620,7 +2620,7 @@ ATF_TP_ADD_TCS(tp)
        ATF_TP_ADD_TC(tp, send_single_mail);
        ATF_TP_ADD_TC(tp, generate_subscription);
        ATF_TP_ADD_TC(tp, generate_subconfirm);
-       ATF_TP_ADD_TC(tp, confirm_sub);
+       ATF_TP_ADD_TC(tp, send_confirmation_mail);
        ATF_TP_ADD_TC(tp, listcontrol);
        ATF_TP_ADD_TC(tp, send_help);
        ATF_TP_ADD_TC(tp, requeuemail);