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 57424543 authored by rswindell's avatar rswindell

Reversed course on the WM_QUOTE mode handling in sbbs_t::postmsg()

(JS bbs.post_msg()): If the WM_QUOTE mode flag is *not* set, then it will auto-
create the quote file (quotes.txt) and add the WM_QUOTE mode bit before calling
sbbs_t::writemsg(). So if existing JS scripts call bbs.post_msg(..., WM_QUOTE)
with a custom-created quote file (e.g. with msg tails), that'll still work as
before (e.g. DDMsgReader.js).

bbs.email() and bbs.netmail() now support an optional reply_header_object
argument which works like bbs.post_msg(). These methods (and the underlying
C++ methods: sbbs_t::email(), netmail(), inetmail(), all auto-create the
quote file now, when the WM_QUOTE mode flag is *not* set.

The auto-created quotes.txt now includes the plain-text version of MIME-encoded
messages.

the bbs.post_msg(), email(), and netmail() methods now all support reply
header objects that came directly from bbs.get_msg_header() *or* copies of
such header objects (but the auto-quoting feature won't work when supplied
this type of header object). So if passed a header object returned from
bbs.get_msg_header(), we can now use the message base (for auto-quoting) and
the underlying msg storage directly (no JS parsing necessary). This is what
the new js_GetMsgHeaderObjectPrivates() function is used for.

js_ParseMsgHeaderObject() (and the underlying parse_header_object() function)
now supports either an actual internally-generated msg header object (e.g.
returned from bbs.get_msg_header()) or one that is a copy or hand-constructed.

quotemsg() no longer tries to get a copy of the msg index/header. It shouldn't
have to since we can now get to underlying msg storage in the js_msgbase.c
via js_GetMsgHeaderObjectPrivates().

quotemsg() now reads only the plain-text portion of MIME-encoded messages.

As part of this effort, I modernized the method prototypes using default
argument values (e.g. WM_NONE for wm_mode arguments) and removed some
extraneous WM_EMAIL and WM_NETMAIL specifications (these wm_mode flags are
automatically added by the sbbs_t::email() and *netmail() functions).

savemsg() now *does* support reply-IDs/thread-linkage via the additional
'remsg' argument (when non-NULL).

Replaced some use of nulstr with NULL.

Replaced more boilerplate SMB open code with calls to smb_open_sub().
parent 121e87b7
......@@ -117,7 +117,7 @@ bool sbbs_t::bulkmail(uchar *ar)
memset(&smb,0,sizeof(smb));
smb.subnum=INVALID_SUB; /* mail database */
i=savemsg(&cfg, &smb, &msg, &client, startup->host_name, msgbuf);
i=savemsg(&cfg, &smb, &msg, &client, startup->host_name, msgbuf, /* remsg: */NULL);
free(msgbuf);
if(i!=0) {
smb_close(&smb);
......
......@@ -43,11 +43,12 @@
/* of message. */
/* Called from functions main_sec, newuser, readmail and scanposts */
/****************************************************************************/
bool sbbs_t::email(int usernumber, const char *top, const char *subj, long mode)
bool sbbs_t::email(int usernumber, const char *top, const char *subj, long mode, smb_t* resmb, smbmsg_t* remsg)
{
char str[256],str2[256],msgpath[256],title[LEN_TITLE+1],ch
char str[256],str2[256],msgpath[256],ch
,buf[SDT_BLOCK_LEN];
char tmp[512];
char title[LEN_TITLE+1] = "";
char* editor=NULL;
uint16_t msgattr=0;
uint16_t xlat=XLAT_NONE;
......@@ -60,13 +61,15 @@ bool sbbs_t::email(int usernumber, const char *top, const char *subj, long mode)
node_t node;
smbmsg_t msg;
SAFECOPY(title,subj);
if(subj != NULL)
SAFECOPY(title, subj);
if(remsg != NULL && title[0] == 0)
SAFECOPY(title, remsg->subj);
if(useron.etoday>=cfg.level_emailperday[useron.level] && !SYSOP && !(useron.exempt&FLAG('M'))) {
bputs(text[TooManyEmailsToday]);
return(false);
}
if(usernumber==1 && useron.rest&FLAG('S')
&& (cfg.node_valuser!=1 || useron.fbacks || useron.emails)) { /* ! val fback */
bprintf(text[R_Feedback],cfg.sys_op);
......@@ -91,7 +94,7 @@ bool sbbs_t::email(int usernumber, const char *top, const char *subj, long mode)
getuserrec(&cfg,usernumber,U_NETMAIL,LEN_NETMAIL,str);
bprintf(text[UserNetMail],str);
if((mode & WM_FORCEFWD) || text[ForwardMailQ][0]==0 || yesno(text[ForwardMailQ])) /* Forward to netmail address */
return(netmail(str,subj,mode));
return(netmail(str, subj, mode, resmb, remsg));
}
if(sys_status&SS_ABORT) {
bputs(text[Aborted]);
......@@ -117,6 +120,11 @@ bool sbbs_t::email(int usernumber, const char *top, const char *subj, long mode)
if(cfg.sys_misc&SM_DELREADM)
msgattr|=MSG_KILLREAD;
if(remsg != NULL && resmb != NULL && !(mode&WM_QUOTE)) {
if(quotemsg(resmb, remsg, /* include tails: */true))
mode |= WM_QUOTE;
}
msg_tmp_fname(useron.xedit, msgpath, sizeof(msgpath));
username(&cfg,usernumber,str2);
if(!writemsg(msgpath,top, /* subj: */title,WM_EMAIL|mode,INVALID_SUB,/* to: */str2,/* from: */useron.alias, &editor)) {
......@@ -182,20 +190,14 @@ bool sbbs_t::email(int usernumber, const char *top, const char *subj, long mode)
errormsg(WHERE,ERR_OPEN,"MAIL",i);
return(false);
}
sprintf(smb.file,"%smail", cfg.data_dir);
smb.retry_time=cfg.smb_retry_time;
smb.subnum=INVALID_SUB;
if((i=smb_open(&smb))!=0) {
if((i=smb_open_sub(&cfg, &smb, INVALID_SUB))!=0) {
smb_stack(&smb,SMB_STACK_POP);
errormsg(WHERE,ERR_OPEN,smb.file,i,smb.last_error);
return(false);
}
if(smb_fgetlength(smb.shd_fp)<1) { /* Create it if it doesn't exist */
smb.status.max_crcs=cfg.mail_maxcrcs;
smb.status.max_age=cfg.mail_maxage;
smb.status.max_msgs=0;
smb.status.attr=SMB_EMAIL;
if((i=smb_create(&smb))!=0) {
smb_close(&smb);
smb_stack(&smb,SMB_STACK_POP);
......@@ -313,7 +315,7 @@ bool sbbs_t::email(int usernumber, const char *top, const char *subj, long mode)
smb_hfield_str(&msg,SUBJECT,title);
add_msg_ids(&cfg, &smb, &msg, /* remsg: */NULL);
add_msg_ids(&cfg, &smb, &msg, remsg);
if(editor!=NULL)
smb_hfield_str(&msg,SMB_EDITOR,editor);
......
......@@ -181,16 +181,16 @@ int sbbs_t::exec_function(csi_t *csi)
case CS_MAIL_SEND: /* Send E-mail */
if(strchr(csi->str,'@')) {
i=1;
netmail(csi->str,nulstr,0);
netmail(csi->str);
}
else if((i=finduser(csi->str))!=0
|| (cfg.msg_misc&MM_REALNAME && (i=userdatdupe(0,U_NAME,LEN_NAME,csi->str))!=0))
email(i,nulstr,nulstr,WM_EMAIL);
email(i);
csi->logic=!i;
return(0);
case CS_MAIL_SEND_FEEDBACK: /* Feedback */
if((i=finduser(csi->str))!=0)
email(i,text[ReFeedback],nulstr,WM_EMAIL);
email(i,text[ReFeedback]);
csi->logic=!i;
return(0);
case CS_MAIL_SEND_NETMAIL:
......@@ -199,7 +199,7 @@ int sbbs_t::exec_function(csi_t *csi)
bputs(text[EnterNetMailAddress]);
csi->logic=LOGIC_FALSE;
if(getstr(str,60,K_LINE)) {
if(netmail(str,nulstr,cmd == CS_MAIL_SEND_NETFILE ? WM_FILE : 0)) {
if(netmail(str, NULL, cmd == CS_MAIL_SEND_NETFILE ? WM_FILE : WM_NONE)) {
csi->logic=LOGIC_TRUE;
}
}
......@@ -208,11 +208,11 @@ int sbbs_t::exec_function(csi_t *csi)
case CS_MAIL_SEND_FILE: /* Upload Attached File to E-mail */
if(strchr(csi->str,'@')) {
i=1;
netmail(csi->str,nulstr,WM_FILE);
netmail(csi->str,NULL,WM_FILE);
}
else if((i=finduser(csi->str))!=0
|| (cfg.msg_misc&MM_REALNAME && (i=userdatdupe(0,U_NAME,LEN_NAME,csi->str))!=0))
email(i,nulstr,nulstr,WM_EMAIL|WM_FILE);
email(i,NULL,NULL,WM_FILE);
csi->logic=!i;
return(0);
case CS_MAIL_SEND_BULK:
......
......@@ -100,12 +100,12 @@ bool sbbs_t::lookup_netuser(char *into)
/****************************************************************************/
/* Send FidoNet/QWK/Internet NetMail from BBS */
/****************************************************************************/
bool sbbs_t::netmail(const char *into, const char *title, long mode)
bool sbbs_t::netmail(const char *into, const char *title, long mode, smb_t* resmb, smbmsg_t* remsg)
{
char str[256],fname[128],*buf,*p,ch;
char to[FIDO_NAME_LEN];
char from[FIDO_NAME_LEN];
char subj[FIDO_SUBJ_LEN];
char to[FIDO_NAME_LEN] = "";
char from[FIDO_NAME_LEN]= "";
char subj[FIDO_SUBJ_LEN]= "";
char msgpath[MAX_PATH+1];
char tmp[512];
char* editor=NULL;
......@@ -127,9 +127,19 @@ bool sbbs_t::netmail(const char *into, const char *title, long mode)
bputs(text[NoNetMailAllowed]);
return false;
}
SAFECOPY(subj, title);
SAFECOPY(to, into);
if(title != NULL)
SAFECOPY(subj, title);
if(into != NULL)
SAFECOPY(to, into);
if(remsg != NULL) {
if(subj[0] == 0 && remsg->subj != NULL)
SAFECOPY(subj, remsg->subj);
if(to[0] == 0 && remsg->from != NULL)
SAFECOPY(to, remsg->from);
// if(addr[0] == 0 && remsg->from_net.addr != NULL)
// smb_netaddrstr(&remsg->from_net, addr);
}
lookup_netuser(to);
......@@ -140,7 +150,7 @@ bool sbbs_t::netmail(const char *into, const char *title, long mode)
bputs(text[EmailFilesNotAllowed]);
mode&=~WM_FILE;
}
qnetmail(to,title,mode|WM_NETMAIL);
qnetmail(to, title, mode);
return false;
}
if(net_type == NET_INTERNET) {
......@@ -152,7 +162,7 @@ bool sbbs_t::netmail(const char *into, const char *title, long mode)
bputs(text[EmailFilesNotAllowed]);
mode&=~WM_FILE;
}
return inetmail(into,title,mode|WM_NETMAIL);
return inetmail(into, title, mode, resmb, remsg);
}
p=strrchr(to,'@'); /* Find '@' in name@addr */
if(p==NULL || net_type != NET_FIDO) {
......@@ -218,6 +228,11 @@ bool sbbs_t::netmail(const char *into, const char *title, long mode)
if(cfg.netmail_misc&NMAIL_KILL) msg.hdr.netattr |= MSG_KILLSENT;
if(mode&WM_FILE) msg.hdr.auxattr |= MSG_FILEATTACH;
if(remsg != NULL && resmb != NULL && !(mode&WM_QUOTE)) {
if(quotemsg(resmb, remsg, /* include tails: */true))
mode |= WM_QUOTE;
}
msg_tmp_fname(useron.xedit, msgpath, sizeof(msgpath));
if(!writemsg(msgpath,nulstr,subj,WM_NETMAIL|mode,INVALID_SUB, into, from, &editor)) {
bputs(text[Aborted]);
......@@ -339,7 +354,7 @@ bool sbbs_t::netmail(const char *into, const char *title, long mode)
smb_t smb;
memset(&smb, 0, sizeof(smb));
smb.subnum = INVALID_SUB;
int result = savemsg(&cfg, &smb, &msg, &client, startup->host_name, buf);
int result = savemsg(&cfg, &smb, &msg, &client, startup->host_name, buf, remsg);
free(buf);
smb_close(&smb);
smb_freemsgmem(&msg);
......
......@@ -2600,9 +2600,14 @@ js_email(JSContext *cx, uintN argc, jsval *arglist)
char* subj=(char *)def;
JSString* js_top=NULL;
JSString* js_subj=NULL;
JSObject* hdrobj;
sbbs_t* sbbs;
smb_t* resmb = NULL;
smbmsg_t* remsg = NULL;
smbmsg_t msg;
jsrefcount rc;
ZERO_VAR(msg);
JS_SET_RVAL(cx, arglist, JSVAL_VOID);
if((sbbs=js_GetPrivate(cx, JS_THIS_OBJECT(cx, arglist)))==NULL)
......@@ -2624,6 +2629,15 @@ js_email(JSContext *cx, uintN argc, jsval *arglist)
js_top=JS_ValueToString(cx,argv[i]);
else if(JSVAL_IS_STRING(argv[i]))
js_subj=JS_ValueToString(cx,argv[i]);
else if(JSVAL_IS_OBJECT(argv[i])) {
if((hdrobj = JSVAL_TO_OBJECT(argv[i])) == NULL)
return JS_FALSE;
if(!js_GetMsgHeaderObjectPrivates(cx, hdrobj, &resmb, &remsg)) {
if(!js_ParseMsgHeaderObject(cx, hdrobj, &msg))
return JS_FALSE;
remsg = &msg;
}
}
}
if(js_top!=NULL)
......@@ -2639,7 +2653,8 @@ js_email(JSContext *cx, uintN argc, jsval *arglist)
}
rc=JS_SUSPENDREQUEST(cx);
JS_SET_RVAL(cx, arglist, BOOLEAN_TO_JSVAL(sbbs->email(usernumber,top,subj,mode)));
JS_SET_RVAL(cx, arglist, BOOLEAN_TO_JSVAL(sbbs->email(usernumber, top, subj, mode, resmb, remsg)));
smb_freemsgmem(&msg);
if(top != def)
free(top);
if(subj != def)
......@@ -2647,6 +2662,7 @@ js_email(JSContext *cx, uintN argc, jsval *arglist)
JS_RESUMEREQUEST(cx, rc);
return(JS_TRUE);
}
static JSBool
js_netmail(JSContext *cx, uintN argc, jsval *arglist)
{
......@@ -2656,10 +2672,15 @@ js_netmail(JSContext *cx, uintN argc, jsval *arglist)
char* subj=(char *)def;
JSString* js_to;
JSString* js_subj=NULL;
JSObject* hdrobj;
sbbs_t* sbbs;
char* cstr;
smb_t* resmb = NULL;
smbmsg_t* remsg = NULL;
smbmsg_t msg;
jsrefcount rc;
ZERO_VAR(msg);
JS_SET_RVAL(cx, arglist, JSVAL_VOID);
if(!js_argc(cx, argc, 1))
......@@ -2678,6 +2699,15 @@ js_netmail(JSContext *cx, uintN argc, jsval *arglist)
}
else if(JSVAL_IS_STRING(argv[i]))
js_subj=JS_ValueToString(cx,argv[i]);
else if(JSVAL_IS_OBJECT(argv[i])) {
if((hdrobj = JSVAL_TO_OBJECT(argv[i])) == NULL)
return JS_FALSE;
if(!js_GetMsgHeaderObjectPrivates(cx, hdrobj, &resmb, &remsg)) {
if(!js_ParseMsgHeaderObject(cx, hdrobj, &msg))
return JS_FALSE;
remsg = &msg;
}
}
}
if(js_subj!=NULL) {
......@@ -2693,7 +2723,8 @@ js_netmail(JSContext *cx, uintN argc, jsval *arglist)
return JS_FALSE;
}
rc=JS_SUSPENDREQUEST(cx);
JS_SET_RVAL(cx, arglist, BOOLEAN_TO_JSVAL(sbbs->netmail(cstr,subj,mode)));
JS_SET_RVAL(cx, arglist, BOOLEAN_TO_JSVAL(sbbs->netmail(cstr, subj, mode, resmb, remsg)));
smb_freemsgmem(&msg);
if(subj != def)
free(subj);
free(cstr);
......@@ -3487,7 +3518,8 @@ js_post_msg(JSContext *cx, uintN argc, jsval *arglist)
uintN n;
JSObject* hdrobj;
sbbs_t* sbbs;
smbmsg_t* remsg=NULL;
smb_t* resmb = NULL;
smbmsg_t* remsg = NULL;
smbmsg_t msg;
jsrefcount rc;
......@@ -3510,15 +3542,17 @@ js_post_msg(JSContext *cx, uintN argc, jsval *arglist)
}
else if(JSVAL_IS_OBJECT(argv[n])) {
if((hdrobj=JSVAL_TO_OBJECT(argv[n]))==NULL)
return(JS_TRUE);
remsg=&msg;
if(!js_ParseMsgHeaderObject(cx,hdrobj,remsg))
return(JS_FALSE);
return JS_FALSE;
if(!js_GetMsgHeaderObjectPrivates(cx, hdrobj, &resmb, &remsg)) {
if(!js_ParseMsgHeaderObject(cx, hdrobj, &msg))
return JS_FALSE;
remsg = &msg;
}
}
}
rc=JS_SUSPENDREQUEST(cx);
JS_SET_RVAL(cx, arglist, BOOLEAN_TO_JSVAL(sbbs->postmsg(subnum,remsg,mode)));
JS_SET_RVAL(cx, arglist, BOOLEAN_TO_JSVAL(sbbs->postmsg(subnum, mode, resmb, remsg)));
smb_freemsgmem(&msg);
JS_RESUMEREQUEST(cx, rc);
......@@ -4067,12 +4101,12 @@ static jsSyncMethodSpec js_bbs_functions[] = {
"(see <tt>MAIL_*</tt> in <tt>sbbsdefs.js</tt> for valid <i>which</i> values)")
,310
},
{"email", js_email, 1, JSTYPE_BOOLEAN, JSDOCSTR("to_user_number [,mode=<tt>WM_EMAIL</tt>] [,top=<i>none</i>] [,subject=<i>none</i>]")
,JSDOCSTR("send private e-mail to a local user")
{"email", js_email, 1, JSTYPE_BOOLEAN, JSDOCSTR("to_user_number [,mode=<tt>WM_EMAIL</tt>] [,top=<i>none</i>] [,subject=<i>none</i>] [,object reply_header]")
,JSDOCSTR("send private e-mail to a local user (<i>reply_header</i> added in v3.17c)")
,310
},
{"netmail", js_netmail, 1, JSTYPE_BOOLEAN, JSDOCSTR("address [,mode=<tt>WM_NONE</tt>] [,subject=<i>none</i>]")
,JSDOCSTR("send private netmail")
{"netmail", js_netmail, 1, JSTYPE_BOOLEAN, JSDOCSTR("address [,mode=<tt>WM_NONE</tt>] [,subject=<i>none</i>] [,object reply_header]")
,JSDOCSTR("send private netmail (<i>reply_header</i> added in v3.17c)")
,310
},
{"bulk_mail", js_bulkmail, 0, JSTYPE_VOID, JSDOCSTR("[ars]")
......@@ -4106,7 +4140,7 @@ static jsSyncMethodSpec js_bbs_functions[] = {
,JSDOCSTR("post a message in the specified message sub-board (number or internal code) "
"with optinal <i>mode</i> (bitfield)<br>"
"If <i>reply_header</i> is specified (a header object returned from <i>MsgBase.get_msg_header()</i>), that header "
"will be used for the in-reply-to header fields (this argument added in v3.13)")
"will be used for the in-reply-to header fields.")
,313
},
{"cfg_msg_scan", js_msgscan_cfg, 0, JSTYPE_VOID, JSDOCSTR("[type=<tt>SCAN_CFG_NEW</tt>]")
......
This diff is collapsed.
......@@ -3519,7 +3519,7 @@ static void smtp_thread(void* arg)
smb_hfield_str(&msg, RECIPIENT, rcpt_name);
smb.subnum=subnum;
if((i=savemsg(&scfg, &smb, &msg, &client, startup->host_name, msgbuf))!=SMB_SUCCESS) {
if((i=savemsg(&scfg, &smb, &msg, &client, startup->host_name, msgbuf, /* remsg: */NULL))!=SMB_SUCCESS) {
lprintf(LOG_WARNING,"%04d %s !ERROR %d (%s) posting message to %s (%s)"
,socket, client.protocol, i, smb.last_error, scfg.sub[subnum]->sname, smb.file);
sockprintf(socket,client.protocol,session, "452 ERROR %d (%s) posting message"
......@@ -3625,7 +3625,7 @@ static void smtp_thread(void* arg)
/* E-mail */
smb.subnum=INVALID_SUB;
/* creates message data, but no header or index records (since msg.to==NULL) */
i=savemsg(&scfg, &smb, &msg, &client, startup->host_name, msgbuf);
i=savemsg(&scfg, &smb, &msg, &client, startup->host_name, msgbuf, /* remsg: */NULL);
free(msgbuf);
if(i!=SMB_SUCCESS) {
smb_close(&smb);
......
......@@ -40,11 +40,14 @@
/****************************************************************************/
/****************************************************************************/
bool sbbs_t::inetmail(const char *into, const char *subj, long mode)
bool sbbs_t::inetmail(const char *into, const char *subj, long mode, smb_t* resmb, smbmsg_t* remsg)
{
char str[256],str2[256],msgpath[256],title[256],name[256],ch
,buf[SDT_BLOCK_LEN],*p,addr[256];
char str[256],str2[256],msgpath[256],ch
,buf[SDT_BLOCK_LEN],*p;
char tmp[512];
char title[256] = "";
char name[256] = "";
char addr[256] = "";
char* editor=NULL;
char your_addr[128];
ushort xlat=XLAT_NONE,net=NET_INTERNET;
......@@ -59,9 +62,20 @@ bool sbbs_t::inetmail(const char *into, const char *subj, long mode)
return(false);
}
SAFECOPY(name,into);
SAFECOPY(addr,into);
SAFECOPY(title,subj);
if(into != NULL) {
SAFECOPY(name,into);
SAFECOPY(addr,into);
}
if(subj != NULL)
SAFECOPY(title,subj);
if(remsg != NULL) {
if(title[0] == 0 && remsg->subj != NULL)
SAFECOPY(title, remsg->subj);
if(name[0] == 0 && remsg->from != NULL)
SAFECOPY(name, remsg->from);
if(addr[0] == 0 && remsg->from_net.addr != NULL)
smb_netaddrstr(&remsg->from_net, addr);
}
if((!SYSOP && !(cfg.inetmail_misc&NMAIL_ALLOW)) || useron.rest&FLAG('M')) {
bputs(text[NoNetMailAllowed]);
......@@ -95,8 +109,13 @@ bool sbbs_t::inetmail(const char *into, const char *subj, long mode)
action=NODE_SMAL;
nodesync();
if(remsg != NULL && resmb != NULL && !(mode&WM_QUOTE)) {
if(quotemsg(resmb, remsg, /* include tails: */true))
mode |= WM_QUOTE;
}
SAFEPRINTF(msgpath,"%snetmail.msg",cfg.node_dir);
if(!writemsg(msgpath,nulstr,title,mode,INVALID_SUB,into,/* from: */your_addr,&editor)) {
if(!writemsg(msgpath,nulstr,title,WM_NETMAIL|mode,INVALID_SUB,into,/* from: */your_addr,&editor)) {
bputs(text[Aborted]);
return(false);
}
......@@ -258,7 +277,7 @@ bool sbbs_t::inetmail(const char *into, const char *subj, long mode)
smb_hfield_str(&msg,SUBJECT,title);
add_msg_ids(&cfg, &smb, &msg, /* remsg: */NULL);
add_msg_ids(&cfg, &smb, &msg, remsg);
if(editor!=NULL)
smb_hfield_str(&msg,SMB_EDITOR,editor);
......@@ -348,7 +367,7 @@ bool sbbs_t::qnetmail(const char *into, const char *subj, long mode)
nodesync();
SAFEPRINTF(msgpath,"%snetmail.msg",cfg.node_dir);
if(!writemsg(msgpath,nulstr,title,mode|WM_QWKNET,INVALID_SUB,to,/* from: */useron.alias,&editor)) {
if(!writemsg(msgpath,nulstr,title, (mode|WM_QWKNET|WM_NETMAIL) ,INVALID_SUB,to,/* from: */useron.alias,&editor)) {
bputs(text[Aborted]);
return(false);
}
......
......@@ -425,11 +425,11 @@ BOOL sbbs_t::newuser()
safe_snprintf(str,sizeof(str),text[NewUserFeedbackHdr]
,nulstr,getage(&cfg,useron.birth),useron.sex,useron.birth
,useron.name,useron.phone,useron.comp,useron.modem);
email(cfg.node_valuser,str,"New User Validation",WM_EMAIL|WM_SUBJ_RO|WM_FORCEFWD);
email(cfg.node_valuser,str,"New User Validation",WM_SUBJ_RO|WM_FORCEFWD);
if(!useron.fbacks && !useron.emails) {
if(online) { /* didn't hang up */
bprintf(text[NoFeedbackWarning],username(&cfg,cfg.node_valuser,tmp));
email(cfg.node_valuser,str,"New User Validation",WM_EMAIL|WM_SUBJ_RO|WM_FORCEFWD);
email(cfg.node_valuser,str,"New User Validation",WM_SUBJ_RO|WM_FORCEFWD);
} /* give 'em a 2nd try */
if(!useron.fbacks && !useron.emails) {
bprintf(text[NoFeedbackWarning],username(&cfg,cfg.node_valuser,tmp));
......
......@@ -36,37 +36,27 @@
#include "sbbs.h"
int msgbase_open(scfg_t* cfg, smb_t* smb, int* storage, long* dupechk_hashes, uint16_t* xlat)
int msgbase_open(scfg_t* cfg, smb_t* smb, unsigned int subnum, int* storage, long* dupechk_hashes, uint16_t* xlat)
{
int i;
*dupechk_hashes=SMB_HASH_SOURCE_DUPE;
*xlat=XLAT_NONE;
smb->retry_time=cfg->smb_retry_time;
if((i=smb_open_sub(cfg, smb, subnum)) != SMB_SUCCESS)
return i;
if(smb->subnum==INVALID_SUB) {
safe_snprintf(smb->file,sizeof(smb->file),"%smail",cfg->data_dir);
smb->status.max_crcs=cfg->mail_maxcrcs;
smb->status.max_age=cfg->mail_maxage;
smb->status.max_msgs=0; /* unlimited */
smb->status.attr=SMB_EMAIL;
/* duplicate message-IDs must be allowed in mail database */
*dupechk_hashes&=~(1<<SMB_HASH_SOURCE_MSG_ID);
} else {
safe_snprintf(smb->file,sizeof(smb->file),"%s%s",cfg->sub[smb->subnum]->data_dir,cfg->sub[smb->subnum]->code);
smb->status.max_crcs=cfg->sub[smb->subnum]->maxcrcs;
smb->status.max_msgs=cfg->sub[smb->subnum]->maxmsgs;
smb->status.max_age=cfg->sub[smb->subnum]->maxage;
smb->status.attr=0;
if(cfg->sub[smb->subnum]->misc&SUB_LZH)
*xlat=XLAT_LZH;
}
if(smb->status.max_crcs==0) /* no CRC checking means no body text dupe checking */
*dupechk_hashes&=~(1<<SMB_HASH_SOURCE_BODY);
if((i=smb_open(smb)) != SMB_SUCCESS)
return i;
if(filelength(fileno(smb->shd_fp)) < 1) /* MsgBase doesn't exist yet, create it */
i=smb_create(smb);
......@@ -80,16 +70,18 @@ int msgbase_open(scfg_t* cfg, smb_t* smb, int* storage, long* dupechk_hashes, ui
/* Posts a message on sub-board number 'subnum' */
/* Returns true if posted, false if not. */
/****************************************************************************/
bool sbbs_t::postmsg(uint subnum, smbmsg_t *remsg, long wm_mode)
bool sbbs_t::postmsg(uint subnum, long wm_mode, smb_t* resmb, smbmsg_t* remsg)
{
char str[256],title[LEN_TITLE+1],top[256];
char touser[64];
char str[256];
char title[LEN_TITLE+1] = "";
char top[256] = "";
char touser[64] = "";
char from[64];
char tags[64] = "";
char* editor=NULL;
char* msgbuf=NULL;
uint16_t xlat;
ushort msgattr;
ushort msgattr = 0;
int i,storage;
long dupechk_hashes;
long length;
......@@ -116,11 +108,6 @@ bool sbbs_t::postmsg(uint subnum, smbmsg_t *remsg, long wm_mode)
,smb_zonestr(remsg->hdr.when_written.zone,NULL));
if(remsg->tags != NULL)
SAFECOPY(tags, remsg->tags);
} else {
title[0]=0;
touser[0]=0;
top[0]=0;
msgattr=0;
}
/* Security checks */
......@@ -215,16 +202,15 @@ bool sbbs_t::postmsg(uint subnum, smbmsg_t *remsg, long wm_mode)
return(false);
}
smb.subnum=subnum;
if((i=msgbase_open(&cfg,&smb,&storage,&dupechk_hashes,&xlat))!=SMB_SUCCESS) {
if((i=msgbase_open(&cfg,&smb,subnum,&storage,&dupechk_hashes,&xlat))!=SMB_SUCCESS) {
errormsg(WHERE,ERR_OPEN,smb.file,i,smb.last_error);
smb_stack(&smb,SMB_STACK_POP);
return(false);
}
if(remsg != NULL && (wm_mode&WM_QUOTE)) {
if(!quotemsg(&smb, remsg, /* include tails: */FALSE))
wm_mode &= ~WM_QUOTE;
if(remsg != NULL && resmb != NULL && !(wm_mode&WM_QUOTE)) {
if(quotemsg(resmb, remsg))
wm_mode |= WM_QUOTE;
}
if(!writemsg(str,top,title,wm_mode,subnum,touser
......@@ -387,8 +373,7 @@ 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)
extern "C" int DLLCALL savemsg(scfg_t* cfg, smb_t* smb, smbmsg_t* msg, client_t* client, const char* server, char* msgbuf, smbmsg_t* remsg)
{
ushort xlat=XLAT_NONE;
int i;
......@@ -461,7 +446,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);
add_msg_ids(cfg, smb, msg, /* remsg: */NULL);
add_msg_ids(cfg, smb, msg, remsg);
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 */) {
......
......@@ -437,8 +437,6 @@ void sbbs_t::readmail(uint usernumber, int which, long lm_mode)
break;
}
quotemsg(&smb, &msg,/* include tails: */TRUE);
if(msg.from_net.addr==NULL)
SAFECOPY(str,msg.from);
else if(msg.from_net.type==NET_FIDO) /* FidoNet type */
......@@ -468,16 +466,16 @@ void sbbs_t::readmail(uint usernumber, int which, long lm_mode)