Move our EOF_MARKER definition to defs. Look for frames using their from/to address, instead of tags

This commit is contained in:
Deon George 2024-12-07 20:19:42 +11:00
parent df1bad1c29
commit 32c9ed7f1b
3 changed files with 10 additions and 7 deletions

View File

@ -15,6 +15,7 @@ const FRAMES_HOME = ANSITEX_HOME+'/text/';
const FRAMES_MSG_BASE = 'vtx_data'; const FRAMES_MSG_BASE = 'vtx_data';
/* Load frames from files */ /* Load frames from files */
const FRAMES_MSG_FILES = true; const FRAMES_MSG_FILES = true;
const FRAMES_EOF_MARKER = "\r\n=== EOF";
const PAGE_LENGTH = 4; // The size of our page tag as stored in the msgbase for echomail/netmail const PAGE_LENGTH = 4; // The size of our page tag as stored in the msgbase for echomail/netmail
const NUMERIC_REGEX = /^[0-9]*$/; const NUMERIC_REGEX = /^[0-9]*$/;

View File

@ -163,7 +163,7 @@ function MsgArea() {
var headers = msgbase.get_all_msg_headers(false,false) || []; var headers = msgbase.get_all_msg_headers(false,false) || [];
for (var i in headers) { for (var i in headers) {
if ((! (headers[i].attr&MSG_DELETE)) && headers[i].tags && ((! regex) || regex.test(headers[i].tags))) if ((! (headers[i].attr&MSG_DELETE)) && (headers[i].from === 'SYSTEM') && ((! regex) || regex.test(headers[i].to)))
frames.push(headers[i]); frames.push(headers[i]);
} }
@ -426,10 +426,13 @@ function MsgArea() {
var raw = msgbase.get_msg_body(false,id,false,false,true,true); var raw = msgbase.get_msg_body(false,id,false,false,true,true);
// Our messages are terminated with \r=== EOF // Our messages are terminated with \r=== EOF
if (! /^(.*)\r=== EOF/.test(raw)) var regex = new RegExp('^(.*)'+FRAMES_EOF_MARKER);
if (! regex.test(raw))
return undefined; return undefined;
var content = JSON.parse(LZString.decompressFromBase64(raw.replace(/\r=== EOF[.\s\S]*$/,''))); var regex = new RegExp(FRAMES_EOF_MARKER+'[.\\s\\S]*$');
var content = JSON.parse(LZString.decompressFromBase64(raw.replace(regex,'')));
msgbase.close(); msgbase.close();
} else { } else {

View File

@ -110,8 +110,6 @@ require('sbbsdefs.js','SS_USERON'); // Need for our ANSI colors eg: BG_*
* - load - Load the frame from the msgbase * - load - Load the frame from the msgbase
*/ */
function Page(debug) { function Page(debug) {
const EOF_MARKER = "\r=== EOF";
this.__window__ = { this.__window__ = {
layout: undefined, // Window - Full page content layout: undefined, // Window - Full page content
header: undefined, // Window - Page Title header: undefined, // Window - Page Title
@ -1043,7 +1041,7 @@ function Page(debug) {
return a.number < b.number return a.number < b.number
else else
return (a.when_imported_time < b.when_imported_time); }) return (a.when_imported_time < b.when_imported_time); })
.filter(function(item) { return item.tags === page; }).pop(); .filter(function(item) { return (item.from === 'SYSTEM') && (item.to === page); }).pop();
if (msg === undefined) { if (msg === undefined) {
log(LOG_DEBUG,'|- Frame not found: ['+page.toString()+'] in ['+FRAMES_MSG_BASE+']'); log(LOG_DEBUG,'|- Frame not found: ['+page.toString()+'] in ['+FRAMES_MSG_BASE+']');
@ -1058,6 +1056,7 @@ function Page(debug) {
return false; return false;
contents.content = contents.content[SESSION_EXT]; contents.content = contents.content[SESSION_EXT];
log(LOG_DEBUG,'|/ Content:'+contents.content);
return this.preload(contents,SESSION_EXT); return this.preload(contents,SESSION_EXT);
} }
@ -1307,7 +1306,7 @@ function Page(debug) {
'content': p.raw, 'content': p.raw,
}; };
var body = LZString.compressToBase64(JSON.stringify(page))+EOF_MARKER; var body = LZString.compressToBase64(JSON.stringify(page))+FRAMES_EOF_MARKER;
if (! msgbase.save_msg(hdr,body)) { if (! msgbase.save_msg(hdr,body)) {
log(LOG_ERROR,' ! Error saving frame: ['+this.name.toString()+']'); log(LOG_ERROR,' ! Error saving frame: ['+this.name.toString()+']');