+ struct lddata *ld = (struct lddata *) userdata;
+ if (!ld) return;
+ char buf[SIZ];
+ char *ch;
+
+ ld->msgnum = msgnum;
+ if (msgnum <= 0) return;
+
+ struct CtdlMessage *TheMessage = CtdlFetchMessage(msgnum, 1);
+ if (!TheMessage) return;
+
+ // If the subject line does not contain the name of the room, add it now.
+ if (!bmstrcasestr(TheMessage->cm_fields[eMsgSubject], CC->room.QRname)) {
+ snprintf(buf, sizeof buf, "[%s] %s", CC->room.QRname, TheMessage->cm_fields[eMsgSubject]);
+ CM_SetField(TheMessage, eMsgSubject, buf, strlen(buf));
+ }
+
+ // Reply-to: should be set so that replies come to the list.
+ snprintf(buf, sizeof buf, "room_%s@%s", CC->room.QRname, CtdlGetConfigStr("c_fqdn"));
+ for (ch=buf; *ch; ++ch) {
+ if (isspace(*ch)) *ch = '_';
+ }
+ CM_SetField(TheMessage, eReplyTo, buf, strlen(buf));
+
+ // Errors-to: should be set to our Aide room so we see the notifications.
+
+
+
+
+
+
+ // With that out of the way, let's figure out who this message needs to be sent to.
+ char *recipients = malloc(strlen(ld->netconf));
+ if (recipients) {
+ recipients[0] = 0;
+
+ int config_lines = num_tokens(ld->netconf, '\n');
+ for (int i=0; i<config_lines; ++i) {
+ extract_token(buf, ld->netconf, i, '\n', sizeof buf);
+ if (!strncasecmp(buf, "listrecp|", 9)) {
+ if (recipients[0] != 0) {
+ strcat(recipients, ",");
+ }
+ strcat(recipients, &buf[9]);
+ }
+ if (!strncasecmp(buf, "digestrecp|", 11)) {
+ if (recipients[0] != 0) {
+ strcat(recipients, ",");
+ }
+ strcat(recipients, &buf[11]);
+ }
+ }
+ struct recptypes *valid = validate_recipients(recipients, NULL, 0);
+ if (valid) {
+ long new_msgnum = CtdlSubmitMsg(TheMessage, valid, "");
+ syslog(LOG_DEBUG, "listdeliver: original message <%ld> is now <%ld> outgoing to the list", msgnum, new_msgnum);
+ free_recipients(valid);
+ }
+ }
+ CM_Free(TheMessage);