Synchronet now requires the libarchive development package (e.g. libarchive-dev on Debian-based Linux distros, libarchive.org for more info) to build successfully.

Commit 7446c395 authored by rswindell's avatar rswindell

QWK-reply-posted email/netmail messages did not contain a Message-ID. Really?

So I created a single add_msg_ids() function (mostly migrated from postmsg.cpp)
to make this incredibly easy so any/everywhere that adds a message to a message
base should be able to call it. This function also creates reply-IDs (when
relevant) and program ID (Fido-PID) header fields:
- FIDOPID (always)
- FIDOMSGID (if an echomail post)
- FIDOREPLYID (if an echomail reply-post)
- RFC822MSGID (always)
- RFC822REPLYID (if a reply)
parent 7aa724f6
......@@ -49,7 +49,6 @@ bool sbbs_t::email(int usernumber, const char *top, const char *subj, long mode)
,buf[SDT_BLOCK_LEN];
char tmp[512];
char pid[128];
char msg_id[128];
char* editor=NULL;
uint16_t msgattr=0;
uint16_t xlat=XLAT_NONE;
......@@ -315,10 +314,7 @@ bool sbbs_t::email(int usernumber, const char *top, const char *subj, long mode)
smb_hfield_str(&msg,SUBJECT,title);
/* Generate FidoNet Program Identifier */
smb_hfield_str(&msg,FIDOPID,msg_program_id(pid));
smb_hfield_str(&msg, RFC822MSGID, get_msgid(&cfg, INVALID_SUB, &msg, msg_id, sizeof(msg_id)));
add_msg_ids(&cfg, &smb, &msg, /* remsg: */NULL);
if(editor!=NULL)
smb_hfield_str(&msg,SMB_EDITOR,editor);
......
......@@ -649,6 +649,7 @@ void sbbs_t::qwktonetmail(FILE *rep, char *block, char *into, uchar fromhub)
smb_freemsgmem(&msg);
return;
}
add_msg_ids(&cfg, &smb, &msg, /* remsg: */NULL);
if(smb_fgetlength(smb.shd_fp)<1L) { /* Create it if it doesn't exist */
smb.status.max_crcs=cfg.mail_maxcrcs;
......
......@@ -139,6 +139,10 @@ char* DLLCALL get_msgid(scfg_t* cfg, uint subnum, smbmsg_t* msg, char* msgid, si
return(msgid);
}
/****************************************************************************/
/* Get (or generate) the original message-ID for a reply message */
/* Returns NULL if not a valid reply message */
/****************************************************************************/
char* DLLCALL get_replyid(scfg_t* cfg, smb_t* smb, smbmsg_t* msg, char* msgid, size_t maxlen)
{
smbmsg_t remsg;
......@@ -158,4 +162,91 @@ char* DLLCALL get_replyid(scfg_t* cfg, smb_t* smb, smbmsg_t* msg, char* msgid, s
smb_freemsgmem(&remsg);
return msgid;
}
\ No newline at end of file
}
/****************************************************************************/
/* Add auto-generated message-IDs to a message, if doesn't already have */
/* When remsg != NULL, the message base (smb) must be already opened */
/****************************************************************************/
BOOL DLLCALL add_msg_ids(scfg_t* cfg, smb_t* smb, smbmsg_t* msg, smbmsg_t* remsg)
{
char msg_id[256];
/* Generate FidoNet (FTS-9) MSGID (for messages posted to FTN sub-boards only) */
if(msg->ftn_msgid == NULL && smb->subnum != INVALID_SUB && (cfg->sub[smb->subnum]->misc&SUB_FIDO)) {
if(ftn_msgid(cfg->sub[smb->subnum], msg, msg_id, sizeof(msg_id)) != NULL) {
if(smb_hfield_str(msg, FIDOMSGID, msg_id) != SMB_SUCCESS)
return FALSE;
}
}
/* Generate Internet MSG-ID (for all messages) */
if(msg->id == NULL) {
get_msgid(cfg, smb->subnum, msg, msg_id, sizeof(msg_id));
if(smb_hfield_str(msg, RFC822MSGID, msg_id) != SMB_SUCCESS)
return FALSE;
}
/* Generate Reply-IDs (when appropriate) */
if(remsg != NULL) {
if(add_reply_ids(cfg, smb, msg, remsg) != TRUE)
return FALSE;
}
/* Generate FidoNet Program Identifier */
if(msg->ftn_pid == NULL) {
if(smb_hfield_str(msg, FIDOPID, msg_program_id(msg_id, sizeof(msg_id))) != TRUE)
return FALSE;
}
return TRUE; // Success
}
/****************************************************************************/
/* Adds reply-IDs and does some reply/thread-linkage to a new message */
/* Migrated from sbbs_t::postmsg() */
/* The message base (smb) must be already opened successfully */
/****************************************************************************/
BOOL DLLCALL add_reply_ids(scfg_t* cfg, smb_t* smb, smbmsg_t* msg, smbmsg_t* remsg)
{
char* p;
char replyid[256];
msg->hdr.thread_back = remsg->hdr.number; /* needed for threading backward */
if((msg->hdr.thread_id = remsg->hdr.thread_id) == 0)
msg->hdr.thread_id = remsg->hdr.number;
/* Add RFC-822 Reply-ID (generate if necessary) */
if((p = get_replyid(cfg, smb, msg, replyid, sizeof(replyid))) != NULL) {
if(smb_hfield_str(msg, RFC822REPLYID, p) != SMB_SUCCESS)
return FALSE;
}
/* Add FidoNet Reply if original message has FidoNet MSGID */
if(remsg->ftn_msgid != NULL) {
if(smb_hfield_str(msg, FIDOREPLYID, remsg->ftn_msgid) != SMB_SUCCESS)
return FALSE;
}
return TRUE; // Success
}
/****************************************************************************/
/* FTN-compliant "Program Identifier"/PID */
/****************************************************************************/
char* DLLCALL msg_program_id(char* pid, size_t maxlen)
{
char compiler[64];
DESCRIBE_COMPILER(compiler);
snprintf(pid, maxlen, "%.10s %s%c-%s%s %s %s"
,VERSION_NOTICE,VERSION,REVISION,PLATFORM_DESC
#ifdef _DEBUG
," Debug"
#else
,""
#endif
,__DATE__,compiler);
return pid;
}
......@@ -259,8 +259,7 @@ bool sbbs_t::inetmail(const char *into, const char *subj, long mode)
smb_hfield_str(&msg,SUBJECT,title);
/* Generate FidoNet Program Identifier */
smb_hfield_str(&msg,FIDOPID,msg_program_id(pid));
add_msg_ids(&cfg, &smb, &msg, /* remsg: */NULL);
if(editor!=NULL)
smb_hfield_str(&msg,SMB_EDITOR,editor);
......@@ -466,8 +465,7 @@ bool sbbs_t::qnetmail(const char *into, const char *subj, long mode)
smb_hfield_str(&msg,SUBJECT,title);
/* Generate FidoNet Program Identifier */
smb_hfield_str(&msg,FIDOPID,msg_program_id(pid));
add_msg_ids(&cfg, &smb, &msg, /* remsg: */NULL);
if(editor!=NULL)
smb_hfield_str(&msg,SMB_EDITOR,editor);
......
......@@ -36,26 +36,6 @@
#include "sbbs.h"
/****************************************************************************/
/* FTN-compliant "Program Identifier"/PID */
/****************************************************************************/
extern "C" char* DLLCALL msg_program_id(char* pid)
{
char compiler[64];
DESCRIBE_COMPILER(compiler);
sprintf(pid,"%.10s %s%c-%s%s%s %s %s"
,VERSION_NOTICE,VERSION,REVISION,PLATFORM_DESC
,beta_version
#ifdef _DEBUG
," Debug"
#else
,""
#endif
,__DATE__,compiler);
return(pid);
}
int msgbase_open(scfg_t* cfg, smb_t* smb, int* storage, long* dupechk_hashes, uint16_t* xlat)
{
int i;
......@@ -103,7 +83,6 @@ int msgbase_open(scfg_t* cfg, smb_t* smb, int* storage, long* dupechk_hashes, ui
bool sbbs_t::postmsg(uint subnum, smbmsg_t *remsg, long wm_mode)
{
char str[256],title[LEN_TITLE+1],top[256];
char msg_id[256];
char touser[64];
char from[64];
char pid[128];
......@@ -301,24 +280,6 @@ bool sbbs_t::postmsg(uint subnum, smbmsg_t *remsg, long wm_mode)
msg.hdr.number=smb.status.last_msg+1; /* this *should* be the new message number */
if(remsg) {
char* p;
char replyid[256];
msg.hdr.thread_back=remsg->hdr.number; /* needed for threading backward */
if((msg.hdr.thread_id=remsg->hdr.thread_id) == 0)
msg.hdr.thread_id=remsg->hdr.number;
/* Add RFC-822 Reply-ID (generate if necessary) */
if((p = get_replyid(&cfg, &smb, &msg, replyid, sizeof(replyid))) != NULL)
smb_hfield_str(&msg, RFC822REPLYID, p);
/* Add FidoNet Reply if original message has FidoNet MSGID */
if(remsg->ftn_msgid!=NULL)
smb_hfield_str(&msg,FIDOREPLYID,remsg->ftn_msgid);
}
smb_hfield_str(&msg,RECIPIENT,touser);
SAFECOPY(str,cfg.sub[subnum]->misc&SUB_NAME ? useron.name : useron.alias);
......@@ -333,19 +294,7 @@ bool sbbs_t::postmsg(uint subnum, smbmsg_t *remsg, long wm_mode)
smb_hfield_str(&msg,SUBJECT,title);
/* Generate default (RFC822) message-id (always) */
get_msgid(&cfg,subnum,&msg,msg_id,sizeof(msg_id));
smb_hfield_str(&msg,RFC822MSGID,msg_id);
/* Generate FTN (FTS-9) MSGID */
if(cfg.sub[subnum]->misc&SUB_FIDO) {
char* p;
if((p = ftn_msgid(cfg.sub[subnum],&msg,msg_id,sizeof(msg_id))) != NULL)
smb_hfield_str(&msg, FIDOMSGID, p);
}
/* Generate FidoNet Program Identifier */
smb_hfield_str(&msg,FIDOPID,msg_program_id(pid));
add_msg_ids(&cfg, &smb, &msg, remsg);
if(editor!=NULL)
smb_hfield_str(&msg,SMB_EDITOR,editor);
......@@ -429,10 +378,11 @@ extern "C" int DLLCALL msg_client_hfields(smbmsg_t* msg, client_t* client)
}
/* Note: support MSG_BODY only, no tails or other data fields (dfields) */
/* Adds/generates Message-IDs when needed */
/* Does *not* support reply-ID look-up / thread-linkage */
extern "C" int DLLCALL savemsg(scfg_t* cfg, smb_t* smb, smbmsg_t* msg, client_t* client, const char* server, char* msgbuf)
{
char pid[128];
char msg_id[256];
ushort xlat=XLAT_NONE;
int i;
long dupechk_hashes=SMB_HASH_SOURCE_DUPE;
......@@ -504,23 +454,7 @@ extern "C" int DLLCALL savemsg(scfg_t* cfg, smb_t* smb, smbmsg_t* msg, client_t*
if(server!=NULL)
smb_hfield_str(msg,SENDERSERVER,server);
/* Generate RFC-822 Message-id */
if(msg->id==NULL) {
get_msgid(cfg,smb->subnum,msg,msg_id,sizeof(msg_id));
smb_hfield_str(msg,RFC822MSGID,msg_id);
}
/* Generate FidoNet MSGID (for FidoNet sub-boards) */
if(smb->subnum!=INVALID_SUB && cfg->sub[smb->subnum]->misc&SUB_FIDO
&& msg->ftn_msgid==NULL) {
char* p;
if((p = ftn_msgid(cfg->sub[smb->subnum],msg,msg_id,sizeof(msg_id))) != NULL)
smb_hfield_str(msg, FIDOMSGID, p);
}
/* Generate FidoNet Program Identifier */
if(msg->ftn_pid==NULL)
smb_hfield_str(msg,FIDOPID,msg_program_id(pid));
add_msg_ids(cfg, smb, msg, /* remsg: */NULL);
if((i=smb_addmsg(smb,msg,smb_storage_mode(cfg, smb),dupechk_hashes,xlat,(uchar*)msgbuf, /* tail: */NULL))==SMB_SUCCESS
&& msg->to!=NULL /* no recipient means no header created at this stage */) {
......@@ -550,11 +484,7 @@ extern "C" int DLLCALL votemsg(scfg_t* cfg, smb_t* smb, smbmsg_t* msg, const cha
if(msg->hdr.number == 0)
msg->hdr.number = get_new_msg_number(smb);
if(msg->id==NULL) {
char msg_id[256];
get_msgid(cfg, smb->subnum, msg, msg_id, sizeof(msg_id));
smb_hfield_str(msg, RFC822MSGID, msg_id);
}
add_msg_ids(cfg, smb, msg, /* remsg: */NULL);
/* Look-up thread_back if RFC822 Reply-ID was specified */
if(msg->hdr.thread_back == 0 && msg->reply_id != NULL) {
......@@ -617,7 +547,6 @@ extern "C" int DLLCALL closepoll(scfg_t* cfg, smb_t* smb, uint32_t msgnum, const
{
int result;
smbmsg_t msg;
char msg_id[256];
ZERO_VAR(msg);
......@@ -629,8 +558,7 @@ extern "C" int DLLCALL closepoll(scfg_t* cfg, smb_t* smb, uint32_t msgnum, const
msg.hdr.number = get_new_msg_number(smb);
get_msgid(cfg, smb->subnum, &msg, msg_id, sizeof(msg_id));
smb_hfield_str(&msg,RFC822MSGID, msg_id);
add_msg_ids(cfg, smb, &msg, /* remsg: */NULL);
result = smb_addpollclosure(smb, &msg, smb_storage_mode(cfg, smb));
......@@ -650,10 +578,7 @@ extern "C" int DLLCALL postpoll(scfg_t* cfg, smb_t* smb, smbmsg_t* msg)
if(msg->hdr.number == 0)
msg->hdr.number = get_new_msg_number(smb);
if(msg->id==NULL) {
char msg_id[256];
get_msgid(cfg, smb->subnum, msg, msg_id, sizeof(msg_id));
smb_hfield_str(msg, RFC822MSGID, msg_id);
}
add_msg_ids(cfg, smb, msg, /* remsg: */NULL);
return smb_addpoll(smb, msg, smb_storage_mode(cfg, smb));
}
......@@ -1071,7 +1071,6 @@ extern "C" {
DLLEXPORT int DLLCALL closepoll(scfg_t*, smb_t*, uint32_t msgnum, const char* username);
DLLEXPORT void DLLCALL signal_sub_sem(scfg_t*, uint subnum);
DLLEXPORT int DLLCALL msg_client_hfields(smbmsg_t*, client_t*);
DLLEXPORT char* DLLCALL msg_program_id(char* pid);
/* filedat.c */
DLLEXPORT BOOL DLLCALL getfileixb(scfg_t* cfg, file_t* f);
......@@ -1117,10 +1116,13 @@ extern "C" {
DLLEXPORT uint32_t DLLCALL str_to_bits(uint32_t currval, const char *str);
/* msg_id.c */
DLLEXPORT char * DLLCALL ftn_msgid(sub_t* sub, smbmsg_t* msg, char* msgid, size_t);
DLLEXPORT char * DLLCALL get_msgid(scfg_t* cfg, uint subnum, smbmsg_t* msg, char* msgid, size_t);
DLLEXPORT char * DLLCALL get_replyid(scfg_t* cfg, smb_t* smb, smbmsg_t* msg, char* msgid, size_t maxlen);
DLLEXPORT uint32_t DLLCALL get_new_msg_number(smb_t* smb);
DLLEXPORT char * DLLCALL ftn_msgid(sub_t*, smbmsg_t*, char* msgid, size_t);
DLLEXPORT char * DLLCALL get_msgid(scfg_t*, uint subnum, smbmsg_t*, char* msgid, size_t);
DLLEXPORT char * DLLCALL get_replyid(scfg_t*, smb_t*, smbmsg_t*, char* msgid, size_t maxlen);
DLLEXPORT uint32_t DLLCALL get_new_msg_number(smb_t*);
DLLEXPORT BOOL DLLCALL add_msg_ids(scfg_t*, smb_t*, smbmsg_t*, smbmsg_t* remsg);
DLLEXPORT BOOL DLLCALL add_reply_ids(scfg_t*, smb_t*, smbmsg_t*, smbmsg_t* remsg);
DLLEXPORT char* DLLCALL msg_program_id(char* pid, size_t);
/* date_str.c */
DLLEXPORT char * DLLCALL zonestr(short zone);
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment