Skip to content
Snippets Groups Projects
Commit 2813150a authored by rswindell's avatar rswindell
Browse files

New feature (requested by sinister-x), if a msg header object is passed to

bbs.post_msg(), it will be used for the in-relpy-to header fields and thread
linkage automatically.
parent 2c425a73
No related branches found
No related tags found
No related merge requests found
......@@ -2262,22 +2262,39 @@ js_postmsg(JSContext *cx, JSObject *obj, uintN argc, jsval *argv, jsval *rval)
{
long mode=0;
uint subnum;
uintN n;
JSObject* hdrobj;
sbbs_t* sbbs;
smbmsg_t* remsg=NULL;
smbmsg_t msg;
*rval = JSVAL_FALSE;
if((sbbs=(sbbs_t*)JS_GetContextPrivate(cx))==NULL)
return(JS_FALSE);
subnum=get_subnum(cx,sbbs,argv[0]);
if(subnum>=sbbs->cfg.total_subs) { // invalid sub-board
*rval = JSVAL_FALSE;
if(subnum>=sbbs->cfg.total_subs) // invalid sub-board
return(JS_TRUE);
ZERO_VAR(msg);
for(n=1; n<argc; n++) {
if(JSVAL_IS_NUMBER(argv[n]))
JS_ValueToInt32(cx,argv[n],(int32*)&mode);
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_TRUE);
}
}
if(argc>1 && JSVAL_IS_NUMBER(argv[1]))
JS_ValueToInt32(cx,argv[1],(int32*)&mode);
*rval = BOOLEAN_TO_JSVAL(sbbs->postmsg(subnum,remsg,mode));
smb_freemsgmem(&msg);
*rval = BOOLEAN_TO_JSVAL(sbbs->postmsg(subnum,NULL,mode));
return(JS_TRUE);
}
......@@ -2635,9 +2652,11 @@ static jsSyncMethodSpec js_bbs_functions[] = {
,JSDOCSTR("list extended file information for files in the specified file directory")
,310
},
{"post_msg", js_postmsg, 1, JSTYPE_BOOLEAN, JSDOCSTR("sub-board [,number mode]")
{"post_msg", js_postmsg, 1, JSTYPE_BOOLEAN, JSDOCSTR("sub-board [,number mode] [,object reply_header]")
,JSDOCSTR("post a message in the specified message sub-board (number or internal code) "
"with optinal <i>mode</i> (bitfield)")
"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 (added in v3.13)")
,310
},
{"cfg_msg_scan", js_msgscan_cfg, 0, JSTYPE_VOID, JSDOCSTR("[number type]")
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment