X-Git-Url: https://code.citadel.org/?p=citadel;a=blobdiff_plain;f=citadel%2Fmodules%2Flistsub%2Fserv_listsub.c;h=9cf3fb86c83f9ebf1bb94c8e66eec66771602b2c;hp=4b72e3826cfb1b2c393810fea19066893ca6d8a2;hb=18a23ae97de67506094a26e92f60af36b0036d91;hpb=ad4e53bbbd397b5f429fb9014278ad36bdf8499d diff --git a/citadel/modules/listsub/serv_listsub.c b/citadel/modules/listsub/serv_listsub.c index 4b72e3826..9cf3fb86c 100644 --- a/citadel/modules/listsub/serv_listsub.c +++ b/citadel/modules/listsub/serv_listsub.c @@ -48,6 +48,120 @@ enum { // one of these gets passed to do_subscribe_or_unsubscribe() so it kno }; +/* + * This generates an email with a link the user clicks to confirm a list subscription. + */ +void send_subscribe_confirmation_email(char *roomname, char *emailaddr, char *url, char *confirmation_token) { + // We need a URL-safe representation of the room name + char urlroom[ROOMNAMELEN+10]; + urlesc(urlroom, sizeof(urlroom), roomname); + + char from_address[1024]; + snprintf(from_address, sizeof from_address, "noreply@%s", CtdlGetConfigStr("c_fqdn")); + + char emailtext[SIZ]; + snprintf(emailtext, sizeof emailtext, + "MIME-Version: 1.0\n" + "Content-Type: multipart/alternative; boundary=\"__ctdlmultipart__\"\n" + "\n" + "This is a multipart message in MIME format.\n" + "\n" + "--__ctdlmultipart__\n" + "Content-type: text/plain\n" + "\n" + "Someone (probably you) has submitted a request to subscribe\n" + "<%s> to the <%s> mailing list.\n" + "\n" + "Please go here to confirm this request:\n" + "%s?room=%s&token=%s&cmd=confirm\n" + "\n" + "If this request has been submitted in error and you do not\n" + "wish to receive the <%s> mailing list, simply do nothing,\n" + "and you will not receive any further mailings.\n" + "\n" + "--__ctdlmultipart__\n" + "Content-type: text/html\n" + "\n" + "

Someone (probably you) has submitted a request to subscribe " + "%s to the %s mailing list.

" + "

Please go here to confirm this request:

" + "

" + "%s?room=%s&token=%s&cmd=confirm

" + "

If this request has been submitted in error and you do not " + "wish to receive the %s mailing list, simply do nothing, " + "and you will not receive any further mailings.

" + "\n" + "\n" + "--__ctdlmultipart__--\n" + , + emailaddr, roomname, url, urlroom, confirmation_token, roomname, + emailaddr, roomname, + url, urlroom, confirmation_token, + url, urlroom, confirmation_token, + roomname + ); + + quickie_message("Citadel", from_address, emailaddr, NULL, emailtext, FMT_RFC822, "Please confirm your list subscription"); +} + + +/* + * This generates an email with a link the user clicks to confirm a list unsubscription. + */ +void send_unsubscribe_confirmation_email(char *roomname, char *emailaddr, char *url, char *confirmation_token) { + // We need a URL-safe representation of the room name + char urlroom[ROOMNAMELEN+10]; + urlesc(urlroom, sizeof(urlroom), roomname); + + char from_address[1024]; + snprintf(from_address, sizeof from_address, "noreply@%s", CtdlGetConfigStr("c_fqdn")); + + char emailtext[SIZ]; + snprintf(emailtext, sizeof emailtext, + "MIME-Version: 1.0\n" + "Content-Type: multipart/alternative; boundary=\"__ctdlmultipart__\"\n" + "\n" + "This is a multipart message in MIME format.\n" + "\n" + "--__ctdlmultipart__\n" + "Content-type: text/plain\n" + "\n" + "Someone (probably you) has submitted a request to unsubscribe\n" + "<%s> from the <%s> mailing list.\n" + "\n" + "Please go here to confirm this request:\n" + "%s?room=%s&token=%s&cmd=confirm\n" + "\n" + "If this request has been submitted in error and you still\n" + "wish to receive the <%s> mailing list, simply do nothing,\n" + "and you will remain subscribed.\n" + "\n" + "--__ctdlmultipart__\n" + "Content-type: text/html\n" + "\n" + "

Someone (probably you) has submitted a request to unsubscribe " + "%s from the %s mailing list.

" + "

Please go here to confirm this request:

" + "

" + "%s?room=%s&token=%s&cmd=confirm

" + "

If this request has been submitted in error and you still " + "wish to receive the %s mailing list, simply do nothing, " + "and you will remain subscribed.

" + "\n" + "\n" + "--__ctdlmultipart__--\n" + , + emailaddr, roomname, url, urlroom, confirmation_token, roomname, + emailaddr, roomname, + url, urlroom, confirmation_token, + url, urlroom, confirmation_token, + roomname + ); + + quickie_message("Citadel", from_address, emailaddr, NULL, emailtext, FMT_RFC822, "Please confirm your list subscription"); +} + + /* * "Subscribe" and "Unsubscribe" operations are so similar that they share a function. * The actual subscription doesn't take place here -- we just send out the confirmation request @@ -59,10 +173,6 @@ void do_subscribe_or_unsubscribe(int action, char *emailaddr, char *url) { char buf[1024]; char confirmation_token[40]; - // We need a URL-safe representation of the room name - char urlroom[ROOMNAMELEN+10]; - urlesc(urlroom, sizeof(urlroom), CC->room.QRname); - // Update this room's netconfig with the updated lastsent begin_critical_section(S_NETCONFIGS); char *oldnetconfig = LoadRoomNetConfigFile(CC->room.QRnumber); @@ -113,16 +223,12 @@ void do_subscribe_or_unsubscribe(int action, char *emailaddr, char *url) { if ((action == SUBSCRIBE) && (!is_already_subscribed)) { generate_uuid(confirmation_token); sprintf(&newnetconfig[strlen(newnetconfig)], "subpending|%s|%s|%ld|%s", emailaddr, confirmation_token, time(NULL), url); - - // FIXME now generate the confirmation email - syslog(LOG_DEBUG, "%s?room=%s&token=%s&cmd=confirm", url, urlroom, confirmation_token); + send_subscribe_confirmation_email(CC->room.QRname, emailaddr, url, confirmation_token); } if ((action == UNSUBSCRIBE) && (is_already_subscribed)) { generate_uuid(confirmation_token); sprintf(&newnetconfig[strlen(newnetconfig)], "unsubpending|%s|%s|%ld|%s", emailaddr, confirmation_token, time(NULL), url); - - // FIXME now generate the confirmation email - syslog(LOG_DEBUG, "%s?room=%s&token=%s&cmd=confirm", url, urlroom, confirmation_token); + send_unsubscribe_confirmation_email(CC->room.QRname, emailaddr, url, confirmation_token); } // Write the new netconfig back to disk