X-Git-Url: https://code.citadel.org/?a=blobdiff_plain;f=citadel%2Fjournaling.c;h=375589750db5e8a83e20ce94f1591409bf4e64a6;hb=0387f48886a9395d89eaca01cd40ab751610426f;hp=8af9afdca80668f96c3ddf8bea509c9d485fe9da;hpb=0475c981817d12900332693297a77a9ae7168129;p=citadel.git diff --git a/citadel/journaling.c b/citadel/journaling.c index 8af9afdca..375589750 100644 --- a/citadel/journaling.c +++ b/citadel/journaling.c @@ -1,7 +1,7 @@ /* * Message journaling functions. * - * Copyright (c) 1987-2015 by the citadel.org team + * Copyright (c) 1987-2020 by the citadel.org team * * This program is open source software; you can redistribute it and/or modify * it under the terms of the GNU General Public License version 3. @@ -14,9 +14,7 @@ #include #include - #include "ctdl_module.h" - #include "citserver.h" #include "config.h" #include "user_ops.h" @@ -49,7 +47,6 @@ void JournalBackgroundSubmit(struct CtdlMessage *msg, memset(jptr, 0, sizeof(struct jnlq)); if (recps != NULL) memcpy(&jptr->recps, recps, sizeof(recptypes)); if (!CM_IsEmpty(msg, eAuthor)) jptr->from = strdup(msg->cm_fields[eAuthor]); - if (!CM_IsEmpty(msg, eNodeName)) jptr->node = strdup(msg->cm_fields[eNodeName]); if (!CM_IsEmpty(msg, erFc822Addr)) jptr->rfca = strdup(msg->cm_fields[erFc822Addr]); if (!CM_IsEmpty(msg, eMsgSubject)) jptr->subj = strdup(msg->cm_fields[eMsgSubject]); if (!CM_IsEmpty(msg, emessageId)) jptr->msgn = strdup(msg->cm_fields[emessageId]); @@ -65,14 +62,7 @@ void JournalBackgroundSubmit(struct CtdlMessage *msg, /* * Convert a local user name to an internet email address for the journal - */ - -/* - * TODODRW: change this into a CtdlModuleDo type function that returns alternative address info - * for this local user. Something like CtdlModuleGoGetAddr(char *localuser, int type, char *alt_addr, size_t alt_addr_len) - * where type can be ADDR_EMAIL, ADDR_FIDO, ADDR_UUCP, ADDR_WEB, ADDR_POSTAL etc etc. - * This then begs the question of what should be returned. Is it wise to return a single char* using a comma as a - * delimiter? Or would it be better to return a linked list of some kind? + * FIXME - grab the user's Internet email address from the user record, not from vCard !!!! */ void local_to_inetemail(char *inetemail, char *localuser, size_t inetemail_len) { struct ctdluser us; @@ -116,7 +106,6 @@ void JournalRunQueueMsg(struct jnlq *jmsg) { if ( (journal_recps->num_local > 0) || (journal_recps->num_internet > 0) - || (journal_recps->num_ignet > 0) || (journal_recps->num_room > 0) ) { @@ -130,36 +119,52 @@ void JournalRunQueueMsg(struct jnlq *jmsg) { journal_msg->cm_anon_type = MES_NORMAL; journal_msg->cm_format_type = FMT_RFC822; CM_SetField(journal_msg, eJournal, HKEY("is journal")); - CM_SetField(journal_msg, eAuthor, jmsg->from, strlen(jmsg->from)); - CM_SetField(journal_msg, eNodeName, jmsg->node, strlen(jmsg->node)); - CM_SetField(journal_msg, erFc822Addr, jmsg->rfca, strlen(jmsg->rfca)); - CM_SetField(journal_msg, eMsgSubject, jmsg->subj, strlen(jmsg->subj)); + + if (!IsEmptyStr(jmsg->from)) { + CM_SetField(journal_msg, eAuthor, jmsg->from, -1); + } + + if (!IsEmptyStr(jmsg->rfca)) { + CM_SetField(journal_msg, erFc822Addr, jmsg->rfca, -1); + } + + if (!IsEmptyStr(jmsg->subj)) { + CM_SetField(journal_msg, eMsgSubject, jmsg->subj, -1); + } mblen = snprintf(mime_boundary, sizeof(mime_boundary), "--Citadel-Journal-%08lx-%04x--", time(NULL), ++seq); - rfc822len = strlen(jmsg->rfc822); - + + if (!IsEmptyStr(jmsg->rfc822)) { + rfc822len = strlen(jmsg->rfc822); + } + else { + rfc822len = 0; + } + message_text = NewStrBufPlain(NULL, rfc822len + sizeof(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. + * (The "ExJournalReport" header is consumed by some email retention services which assume the journaling agent is Exchange.) */ StrBufAppendBufPlain( message_text, - HKEY("Content-type: multipart/mixed; boundary=\""), 0); + HKEY("Content-type: multipart/mixed; boundary=\""), + 0 + ); StrBufAppendBufPlain(message_text, mime_boundary, mblen, 0); StrBufAppendBufPlain( message_text, HKEY("\"\r\n" - "Content-Identifer: ExJournalReport\r\n" + "Content-Identifier: ExJournalReport\r\n" "MIME-Version: 1.0\r\n" "\n" - "--"), 0); + "--"), + 0 + ); StrBufAppendBufPlain(message_text, mime_boundary, mblen, 0); @@ -183,78 +188,33 @@ void JournalRunQueueMsg(struct jnlq *jmsg) { StrBufAppendPrintf(message_text, " <%s>", journal_msg->cm_fields[erFc822Addr]); } - else if (!CM_IsEmpty(journal_msg, eNodeName)) { - StrBufAppendPrintf(message_text, " @ %s", - journal_msg->cm_fields[eNodeName]); - } - else - StrBufAppendBufPlain( - message_text, - HKEY(" "), 0); - - StrBufAppendBufPlain( - message_text, - HKEY("\r\n" - "Message-ID: <"), 0); + StrBufAppendBufPlain(message_text, HKEY("\r\nMessage-ID: <"), 0); StrBufAppendBufPlain(message_text, jmsg->msgn, -1, 0); - StrBufAppendBufPlain( - message_text, - HKEY(">\r\n" - "Recipients:\r\n"), 0); + StrBufAppendBufPlain(message_text, HKEY(">\r\nRecipients:\r\n"), 0); if (jmsg->recps.num_local > 0) { for (i=0; irecps.num_local; ++i) { - extract_token(recipient, jmsg->recps.recp_local, - i, '|', sizeof recipient); + extract_token(recipient, jmsg->recps.recp_local, i, '|', sizeof recipient); local_to_inetemail(inetemail, recipient, sizeof inetemail); - StrBufAppendPrintf(message_text, - " %s <%s>\r\n", recipient, inetemail); - } - } - - if (jmsg->recps.num_ignet > 0) { - for (i=0; irecps.num_ignet; ++i) { - extract_token(recipient, jmsg->recps.recp_ignet, - i, '|', sizeof recipient); - StrBufAppendPrintf(message_text, - " %s\r\n", recipient); + StrBufAppendPrintf(message_text, " %s <%s>\r\n", recipient, inetemail); } } if (jmsg->recps.num_internet > 0) { for (i=0; irecps.num_internet; ++i) { - extract_token(recipient, jmsg->recps.recp_internet, - i, '|', sizeof recipient); - StrBufAppendPrintf(message_text, - " %s\r\n", recipient); + extract_token(recipient, jmsg->recps.recp_internet, i, '|', sizeof recipient); + StrBufAppendPrintf(message_text, " %s\r\n", recipient); } } - StrBufAppendBufPlain( - message_text, - HKEY("\r\n" - "--"), 0); - + StrBufAppendBufPlain(message_text, HKEY("\r\n" "--"), 0); StrBufAppendBufPlain(message_text, mime_boundary, mblen, 0); - - StrBufAppendBufPlain( - message_text, - HKEY("\r\n" - "Content-type: message/rfc822\r\n" - "\r\n"), 0); - + StrBufAppendBufPlain(message_text, HKEY("\r\nContent-type: message/rfc822\r\n\r\n"), 0); StrBufAppendBufPlain(message_text, jmsg->rfc822, rfc822len, 0); - - StrBufAppendBufPlain( - message_text, - HKEY("--"), 0); - + StrBufAppendBufPlain(message_text, HKEY("--"), 0); StrBufAppendBufPlain(message_text, mime_boundary, mblen, 0); - - StrBufAppendBufPlain( - message_text, - HKEY("--\r\n"), 0); + StrBufAppendBufPlain(message_text, HKEY("--\r\n"), 0); CM_SetAsFieldSB(journal_msg, eMesageText, &message_text); free(jmsg->rfc822); @@ -263,7 +223,7 @@ void JournalRunQueueMsg(struct jnlq *jmsg) { jmsg->msgn = NULL; /* Submit journal message */ - CtdlSubmitMsg(journal_msg, journal_recps, "", 0); + CtdlSubmitMsg(journal_msg, journal_recps, ""); CM_Free(journal_msg); }