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 39fd9d433a
3 changed files with 9 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=== 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

@ -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
@ -920,7 +918,7 @@ function Page(debug) {
this.name = page; this.name = page;
// Load a page from disk first if it exists // Load a page from disk first if it exists
if (FRAMES_MSG_FILES && this.import(FRAMES_HOME+page.toString(),SESSION_EXT)) if (false && FRAMES_MSG_FILES && this.import(FRAMES_HOME+page.toString(),SESSION_EXT))
return true; return true;
// Fall back to loading from msgbase // Fall back to loading from msgbase
@ -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+']');
@ -1307,7 +1305,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()+']');