X-Git-Url: https://code.citadel.org/?a=blobdiff_plain;f=citadel%2Fjournaling.c;h=0d2e74f4182d2218a042b7a9ea9167de77abbf06;hb=c4609169aa7baf208848e72c16d33a3f892353b8;hp=3dae1074997940f3437c47a6bd1772b916bea618;hpb=655de5af64c89584fbdd0110a27053a9f3bfd138;p=citadel.git diff --git a/citadel/journaling.c b/citadel/journaling.c index 3dae10749..0d2e74f41 100644 --- a/citadel/journaling.c +++ b/citadel/journaling.c @@ -1,5 +1,15 @@ /* * Message journaling functions. + * + * Copyright (c) 1987-2015 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. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. */ #include @@ -8,6 +18,7 @@ #include "ctdl_module.h" #include "citserver.h" +#include "config.h" #include "user_ops.h" #include "serv_vcard.h" /* Needed for vcard_getuser and extract_inet_email_addrs */ #include "internet_addressing.h" @@ -20,7 +31,7 @@ struct jnlq *jnlq = NULL; /* journal queue */ */ void JournalBackgroundSubmit(struct CtdlMessage *msg, StrBuf *saved_rfc822_version, - struct recptypes *recps) { + recptypes *recps) { struct jnlq *jptr = NULL; @@ -36,7 +47,7 @@ void JournalBackgroundSubmit(struct CtdlMessage *msg, return; } memset(jptr, 0, sizeof(struct jnlq)); - if (recps != NULL) memcpy(&jptr->recps, recps, sizeof(struct recptypes)); + 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]); @@ -88,7 +99,7 @@ void local_to_inetemail(char *inetemail, char *localuser, size_t inetemail_len) void JournalRunQueueMsg(struct jnlq *jmsg) { struct CtdlMessage *journal_msg = NULL; - struct recptypes *journal_recps = NULL; + recptypes *journal_recps = NULL; StrBuf *message_text = NULL; char mime_boundary[256]; long mblen; @@ -100,7 +111,7 @@ void JournalRunQueueMsg(struct jnlq *jmsg) { if (jmsg == NULL) return; - journal_recps = validate_recipients(config.c_journal_dest, NULL, 0); + journal_recps = validate_recipients(CtdlGetConfigStr("c_journal_dest"), NULL, 0); if (journal_recps != NULL) { if ( (journal_recps->num_local > 0) @@ -119,16 +130,34 @@ 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, strlen(jmsg->from)); + } + + if (!IsEmptyStr(jmsg->node)) { + CM_SetField(journal_msg, eNodeName, jmsg->node, strlen(jmsg->node)); + } + + if (!IsEmptyStr(jmsg->rfca)) { + CM_SetField(journal_msg, erFc822Addr, jmsg->rfca, strlen(jmsg->rfca)); + } + + if (!IsEmptyStr(jmsg->subj)) { + CM_SetField(journal_msg, eMsgSubject, jmsg->subj, strlen(jmsg->subj)); + } mblen = snprintf(mime_boundary, sizeof(mime_boundary), "--Citadel-Journal-%08lx-%04x--", time(NULL), ++seq); - rfc822len = strlen(jmsg->rfc822); - - message_text = NewStrBufPlain(NULL, rfc822len + sizeof(struct recptypes) + 1024); + + 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.