]> code.citadel.org Git - citadel.git/blobdiff - citadel/journaling.c
* Moved the "Content-Identifer" (sic) header out of the envelope journal
[citadel.git] / citadel / journaling.c
index cd1f5d4e6a61bc625ded1de08c13a950f12c49c8..5cba32940eeecf6719815b9065d01093499e3925 100644 (file)
@@ -97,9 +97,11 @@ void JournalRunQueueMsg(struct jnlq *jmsg) {
        struct recptypes *journal_recps = NULL;
        char *message_text = NULL;
        char mime_boundary[256];
+       char recipient[256];
        static int seq = 0;
+       int i;
 
-       journal_recps = validate_recipients("FIXME@FIXME.com"); /* FIXME */
+       journal_recps = validate_recipients(config.c_journal_dest);
        if (journal_recps != NULL) {
 
                if (  (journal_recps->num_local > 0)
@@ -123,25 +125,82 @@ void JournalRunQueueMsg(struct jnlq *jmsg) {
                        journal_msg->cm_fields['F'] = jmsg->rfca;
                        journal_msg->cm_fields['U'] = jmsg->subj;
 
-                       sprintf(mime_boundary, "---Citadel-Message-Journal-%08lx-%04x---", time(NULL), ++seq);
+                       sprintf(mime_boundary, "--Citadel-Journal-%08lx-%04x--", time(NULL), ++seq);
                        message_text = malloc(strlen(jmsg->rfc822) + sizeof(struct recptypes) + 1024);
 
+                       /*
+                        * Here is where we begin to compose the journalized message.
+                        * NOTE: the superfluous "Content-Identifer: ExJournalReport" header was
+                        *       requested by a paying customer, and yes, it is intentionally
+                        *       spelled wrong.  Do NOT remove or change it.
+                        */
                        sprintf(message_text,
                                "Content-type: multipart/mixed; boundary=\"%s\"\r\n"
+                               "Content-Identifer: ExJournalReport\r\n"
                                "MIME-Version: 1.0\r\n"
                                "\n"
                                "--%s\r\n"
                                "Content-type: text/plain\r\n"
                                "\r\n"
-                               "FIXME PUT MEMO HERE\r\n"
+                               "Sender: %s "
+                       ,
+                               mime_boundary,
+                               mime_boundary,
+                               ( journal_msg->cm_fields['A'] ? journal_msg->cm_fields['A'] : "(null)" )
+                       );
+
+                       if (journal_msg->cm_fields['F']) {
+                               sprintf(&message_text[strlen(message_text)], "<%s>",
+                                       journal_msg->cm_fields['F']);
+                       }
+                       else if (journal_msg->cm_fields['N']) {
+                               sprintf(&message_text[strlen(message_text)], "@ %s",
+                                       journal_msg->cm_fields['N']);
+                       }
+
+                       sprintf(&message_text[strlen(message_text)],
+                               "\r\n"
+                               "Message-ID: <%s>\r\n"
+                               "Recipients:\r\n"
+                       ,
+                               jmsg->msgn
+                       );
+
+                       if (jmsg->recps.num_local > 0) {
+                               for (i=0; i<jmsg->recps.num_local; ++i) {
+                                       extract_token(recipient, jmsg->recps.recp_local,
+                                                       i, '|', sizeof recipient);
+                                       sprintf(&message_text[strlen(message_text)],
+                                               "       %s\r\n", recipient);
+                               }
+                       }
+
+                       if (jmsg->recps.num_ignet > 0) {
+                               for (i=0; i<jmsg->recps.num_ignet; ++i) {
+                                       extract_token(recipient, jmsg->recps.recp_ignet,
+                                                       i, '|', sizeof recipient);
+                                       sprintf(&message_text[strlen(message_text)],
+                                               "       %s\r\n", recipient);
+                               }
+                       }
+
+                       if (jmsg->recps.num_internet > 0) {
+                               for (i=0; i<jmsg->recps.num_internet; ++i) {
+                                       extract_token(recipient, jmsg->recps.recp_internet,
+                                                       i, '|', sizeof recipient);
+                                       sprintf(&message_text[strlen(message_text)],
+                                               "       %s\r\n", recipient);
+                               }
+                       }
+
+                       sprintf(&message_text[strlen(message_text)],
+                               "\r\n"
                                "--%s\r\n"
                                "Content-type: message/rfc822\r\n"
                                "\r\n"
                                "%s"
                                "--%s--\r\n"
                        ,
-                               mime_boundary,
-                               mime_boundary,
                                mime_boundary,
                                jmsg->rfc822,
                                mime_boundary
@@ -168,7 +227,7 @@ void JournalRunQueueMsg(struct jnlq *jmsg) {
  * Run the queue.
  */
 void JournalRunQueue(void) {
-       struct jnlq *jptr;
+       struct jnlq *jptr = NULL;
 
        while (jnlq != NULL) {
                begin_critical_section(S_JOURNAL_QUEUE);