From 641551125bec3e4bdb6dc19139c0afa54ec55dd0 Mon Sep 17 00:00:00 2001 From: Deon George Date: Fri, 6 May 2022 17:41:07 +1000 Subject: [PATCH] Fix for ansitex still running, when user timeout inactive. Fix for calculating unread messages. --- frames_list.js | 17 +++++++++++++++++ load/frame-page.js | 17 ++++++++++++++--- load/funcs.js | 13 +++++++------ main.js | 7 ++++--- text/198a.tex | 2 +- 5 files changed, 43 insertions(+), 13 deletions(-) create mode 100644 frames_list.js diff --git a/frames_list.js b/frames_list.js new file mode 100644 index 0000000..70c6cbe --- /dev/null +++ b/frames_list.js @@ -0,0 +1,17 @@ +load('load/string.js'); +load('load/funcs.js'); +load('ansitex/load/msgbases.js'); + +if (argv.length !== 1) { + writeln('ERROR: Need a msgbase page prefix'); + exit(1); +} + +ma = new MsgAreas(); +area = ma.getArea(argv[0]); + +writeln('Opening ['+argv[0]+'] - ('+area.msgbase.cfg.code+')'); + +for (var x in area.headers) { + writeln(padright(area.headers[x].number,4,' ')+':'+area.headers[x].tags); +} diff --git a/load/frame-page.js b/load/frame-page.js index 49a257a..7f8145a 100644 --- a/load/frame-page.js +++ b/load/frame-page.js @@ -236,17 +236,28 @@ PageFrame.prototype.loadMessage = function(page) { var stats = ma.getUserStats(this.frame); // if this message is to the user, and the msg number > scan_ptr and it is the next message on the user's new mail list - var newmsgs = area.newMsgs(); + var newmsgs = area.newMsgsToMe(); + log(LOG_DEBUG,'User has: '+newmsgs.length+' msgs to read to ME'); if (newmsgs.length) { var next = newmsgs.shift(); + log(LOG_DEBUG,'NEXT is: '+next.tag+' , this is: '+msg.tag); + if (next.tag === msg.tag) stats.scan_ptr = next.number; } // if this message is the next message, update last_read - if (msg.number === stats.last_read+1) - stats.last_read = msg.number; + var newmsgs = area.newMsgs(); + log(LOG_DEBUG,'User has: '+newmsgs.length+' msgs to read'); + if (newmsgs.length) { + var next = newmsgs.shift(); + + log(LOG_DEBUG,'NEXT is: '+next.tag+' , this is: '+msg.tag); + + if (next.tag === msg.tag) + stats.last_read = next.number; + } log(LOG_DEBUG,'Built frame: ['+this.frame+']['+this.index+'] ('+this.page+')'); } diff --git a/load/funcs.js b/load/funcs.js index 8b41f60..3a24efa 100644 --- a/load/funcs.js +++ b/load/funcs.js @@ -180,8 +180,9 @@ function atcode(field,length,pad,context) { break; } - var x = context.getUserStats().last_read+1; - result = (x <= context.msgbase.last_msg) ? context.getMessagePtr(x).date : ''; + var x = context.newMsgs(); + + result = x.length ? x.shift().date : ''; break; case 'msg_area_msgunread_page': @@ -190,8 +191,8 @@ function atcode(field,length,pad,context) { break; } - var x = context.getUserStats().last_read+1; - return (x <= context.msgbase.last_msg) ? context.getMessagePage(x) : null; + var x = context.newMsgs(); + return x.length ? context.getMessagePage(x.shift().number) : null; // First unread message to me case 'msg_area_msgotome_date': @@ -200,7 +201,7 @@ function atcode(field,length,pad,context) { break; } - var x = context.newMsgs(); + var x = context.newMsgsToMe(); result = x.length ? x.shift().date : ''; break; @@ -211,7 +212,7 @@ function atcode(field,length,pad,context) { break; } - var x = context.newMsgs(); + var x = context.newMsgsToMe(); return x.length ? context.getMessagePage(x.shift().number) : null; // Count of unread messages diff --git a/main.js b/main.js index 773dcfb..77ae19a 100644 --- a/main.js +++ b/main.js @@ -120,7 +120,7 @@ while(bbs.online) { */ const viewdata = (client.socket.local_port === 516); - while (action !== ACTION_TERMINATE && action !== ACTION_EXIT) { + while (action !== ACTION_TERMINATE && action !== ACTION_EXIT && bbs.online) { try { bbs.nodesync(); // @todo Stop the display of telegrams @@ -132,7 +132,7 @@ while(bbs.online) { // If we have no action, read from the terminal if (action === false) { // If a special key sequence is coming... - while (esc || ! read) { + while ((esc || ! read) && (action !== ACTION_TERMINATE)) { log(LOG_DEBUG,'- READ START'); // Wait for a key from the user read = console.inkey(K_NONE,inkey_timeout); @@ -185,7 +185,8 @@ while(bbs.online) { // Terminate the user if they have been inactive too long. if (time() > timer+((user.number ? INACTIVE_LOGIN : INACTIVE_NOLOGIN)+INKEY_TIMEOUT)/1000) { fo.sendBaseline('INACTIVE',false); - bbs.hangup(); + action = ACTION_TERMINATE; + log(LOG_INFO,'User INACTIVE - terminating...'); // Idle warning - due to inactivity. } else if (time() > timer+(user.number ? INACTIVE_LOGIN : INACTIVE_NOLOGIN)/1000) { diff --git a/text/198a.tex b/text/198a.tex index 7feab41..f8f87d4 100644 --- a/text/198a.tex +++ b/text/198a.tex @@ -1 +1 @@ -{"version":1,"frame":198,"index":"a","owner":1,"cost":0,"content":"G1swbRtbNzZDG1sxbS4bWzBtDQogG1szM20bWG1zZ19ncnBfbmFtZTs0MBtcG1szMEMbWzM3bRtbMW3awr/Cv7+zG1swbQ0KIBtbMzZtG1htc2dfYXJlYV9hcmVhdGFnOzQwG1wbWzMwQxtbMzdtsyCzwrSzsw0KIBtbMTszNm0bWG1zZ19hcmVhX2Rlc2M7NDAbXBtbMzBDG1sxOzM3bVN1bW1hcnkbWzBtDQobWzE7MzBtxMTExMTExMTExMTExMTExMTExMTExMTExMTExMTExMTExMTExMTExMTExMTExMTExMSzxMTExMTExMTExMTExMTExMTExMTExMTExMTExBtbMG0NCiAbWERBVEVUSU1FOzI0G1wbWzI1QxtbMTszMG2zG1swbSAbWzFtTmV3IE1lc3NhZ2VzIHRvIFlvdRtbMG06IBtbMTszMW0bWG1zZ19hcmVhX25ld3RvbWU7LTUbXBtbMG0NChtbNTBDG1sxOzMwbbMbWzBtICAgICAbWzFtVW5yZWFkIE1lc3NhZ2VzG1swbTogG1sxOzMxbRtYbXNnX2FyZWFfbmV3Oy01G1wbWzBtDQogG1sxOzMybTEbWzM3bSBGaXJzdCB1bnJlYWQgICAbWzM0bRtYbXNnX2FyZWFfbXNndW5yZWFkX2RhdGU7MzEbXBtbMG0gG1sxOzMwbbMbWzBtICAgICAgG1sxbVRvdGFsIE1lc3NhZ2VzG1swbTogG1sxOzMxbRtYbXNnX2FyZWFfdG90YWw7LTUbXBtbMG0NCiAbWzE7MzJtMhtbMG0gG1sxbUZpcnN0IHRvIHlvdRtbM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ICAgICAgICAgIBtbMTszNzs0NG2zG1swOzQ0bSAbWzE7MzJtNhtbMzZtIE5leHQgG1swOzQ0bSAgICAgICAbWzE7MzdtsxtbMDs0NG0gG1sxOzMybTgbWzA7NDRtIBtbMTszNm1SZXBseRtbMDs0NG0gICAgICAgG1sxOzM3bSCzG1swbQ0KIBtbMzJtMCAbWzM3bUJhY2sgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgIBtbMTszNzs0NG2zG1swOzQ0bSAbWzE7MzJtIxtbMDs0NG0gG1sxOzM2bU1zZyBBdHRycxtbMDszNjs0NG0gIBtbMzdtIBtbMTszN22zG1swOzQ0bSAbWzE7MzJtMBtbMDs0NG0gG1sxOzM2bVJldHVybiBoZXJlG1swOzQ0bSAbWzE7MzdtILMbWzBtDQogICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAbWzE7Mzc7NDRt1M3Nzc3Nzc3Nzc3Nzc3Nzc3Nzc3Nzc3Nzc3Nzc3Nzc3NvhtbMG0NCg==","isPublic":0,"isAccessible":1,"type":"m","key":[null,null,null,null,null,null,null,null,null,null],"date":"2022-04-29T00:00:00.000Z"} +{"version":1,"frame":198,"index":"a","owner":1,"cost":0,"content":"G1swbRtbNzZDG1sxbS4bWzBtDQogG1szM20bWG1zZ19ncnBfbmFtZTs0MBtcG1szMEMbWzM3bRtbMW3awr/Cv7+zG1swbQ0KIBtbMzZtG1htc2dfYXJlYV9hcmVhdGFnOzQwG1wbWzMwQxtbMzdtsyCzwrSzsw0KIBtbMTszNm0bWG1zZ19hcmVhX2Rlc2M7NDAbXBtbMzBDG1sxOzM3bVN1bW1hcnkbWzBtDQobWzE7MzBtxMTExMTExMTExMTExMTExMTExMTExMTExMTExMTExMTExMTExMTExMTExMTExMTExMSzxMTExMTExMTExMTExMTExMTExMTExMTExMTExBtbMG0NCiAbWERBVEVUSU1FOzI0G1wbWzI1QxtbMTszMG2zG1swbSAbWzFtTmV3IE1lc3NhZ2VzIH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0KIBtbMzJtNhtbMW0gG1swbVNlYXJjaCBmb3IgTWVzc2FnZSAgICAgICAgICAgICAgICAgICAgICAgIBtbMTs0NG2zG1szM20gryBNZXNzYWdlIFJlYWRpbmcgTmF2aWdhdGlvbiCuG1swOzMzOzQ0bSAbWzE7MzdtsxtbMG0NCiAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgIBtbMTs0NG2zG1szM20gG1szMm0YG1szNm0gU2Nyb2xsIFVQIBtbMDs0NG0gIBtbMW2zG1swOzQ0bSAbWzE7MzJtGRtbMzZtIFNjcm9sbCBET1dOG1swOzQ0bSAbWzE7MzNtIBtbMzdtsxtbMG0NCiAbWzMybTgbWzM3bSBBcmVhIFN1bW1hcnkgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAbWzE7NDRtsxtbMzNtIBtbMDszMjs0NG00G1sxOzM2bSAbWzA7MzY7NDRtUHJldmlvdXMbWzFtICAbWzA7NDRtICAbWzFtsxtbMDs0NG0gG1szMm0zG1sxOzM2bSAbWzA7MzY7NDRtUHJldiBUaHJlYWQbWzM3bSAbWzE7MzNtIBtbMzdtsxtbMG0NCiAbWzE7MzJtMBtbMDszMm0gG1sxOzM3bUJhY2sbWzBtICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAbWzE7NDRtsxtbMzNtIBtbMDszMjs0NG02G1sxOzM2bSAbWzA7MzY7NDRtTmV4dBtbMW0gG1swOzQ0bSAgICAgICAbWzFtsxtbMDs0NG0gG1szMm03G1szN20gG1szNm1OZXh0IFRocmVhZBtbMzdtIBtbMTszM20gG1szN22zG1swbQ0KICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgG1sxOzQ0bbMbWzA7NDRtIBtbMzJtNRtbMzdtIBtbMzZtV3JpdGUgTmV3G1szN20gICAbWzFtsxtbMDs0NG0gG1szMm04G1szN20gG1szNm1SZXBseRtbMzdtICAgICAgIBtbMTszM20gG1szN22zG1swbQ0KICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgG1sxOzQ0bbMbWzA7NDRtIBtbMzJtIxtbMzdtIBtbMzZtTXNnIEF0dHJzICAbWzM3bSAbWzFtsxtbMDs0NG0gG1szMm0wG1szN20gG1szNm1SZXR1cm4gaGVyZRtbMzdtIBtbMTszM20gG1szN22zG1swbQ0KICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgG1sxOzQ0bdTNzc3Nzc3Nzc3Nzc3Nzc3Nzc3Nzc3Nzc3Nzc3Nzc3Nzb4bWzBtDQo=","isPublic":0,"isAccessible":1,"type":"m","key":[null,null,null,null,null,null,null,null,null,null],"date":"2022-04-29T00:00:00.000Z"}