Add a date to our imported messages. Tag our messages with an EOF marker

This commit is contained in:
Deon George 2024-12-07 19:32:42 +11:00
parent da51bd3d0b
commit df1bad1c29
2 changed files with 17 additions and 14 deletions

View File

@ -423,16 +423,14 @@ function MsgArea() {
try {
if (msgbase.open()) {
var content = JSON.parse(LZString.decompressFromBase64(msgbase.get_msg_body(false,id,false,false,true,true)));
msgbase.close();
var raw = msgbase.get_msg_body(false,id,false,false,true,true);
var i;
for (var i=0; i<content.length; i++) {
// Echomail tag line
if (content[i] === '---' || content[i].substring(0,4) === '--- ')
break;
}
content.length = i;
// Our messages are terminated with \r=== EOF
if (! /^(.*)\r=== EOF/.test(raw))
return undefined;
var content = JSON.parse(LZString.decompressFromBase64(raw.replace(/\r=== EOF[.\s\S]*$/,'')));
msgbase.close();
} else {
writeln('*** NOPE WONT OPEN msgbase:'+JSON.stringify(msgbase));

View File

@ -110,6 +110,8 @@ require('sbbsdefs.js','SS_USERON'); // Need for our ANSI colors eg: BG_*
* - load - Load the frame from the msgbase
*/
function Page(debug) {
const EOF_MARKER = "\r=== EOF";
this.__window__ = {
layout: undefined, // Window - Full page content
header: undefined, // Window - Page Title
@ -957,6 +959,7 @@ function Page(debug) {
}
var contents = JSON.parse(f.read());
contents.date = f.date;
f.close();
// Load the page content
@ -1050,6 +1053,10 @@ function Page(debug) {
log(LOG_DEBUG,'|- Loading frame: ['+page.toString()+'] from msgbase ['+msg.number+'] ['+SESSION_EXT+']');
var contents = mb.getContent(msg.number);
if (contents === undefined)
return false;
contents.content = contents.content[SESSION_EXT];
return this.preload(contents,SESSION_EXT);
@ -1249,11 +1256,11 @@ function Page(debug) {
this.cost = contents.cost;
this.key = contents.key;
this.raw = contents.content;
this.date = contents.date;
break;
default:
writeln('here');
log(LOG_ERROR,'|-! Unknown frame version : '+contents.version);
this.get(new PageObject(FRAME_SYSTEM_ERROR));
return null;
@ -1288,7 +1295,7 @@ function Page(debug) {
to: this.name,
from: 'SYSTEM',
tags: this.name,
//date: msgs[x].date,
date: strftime("%a, %d %b %Y, %I:%M:%S %Z",this.date),
subject: 'Content',
};
@ -1300,15 +1307,13 @@ function Page(debug) {
'content': p.raw,
};
var body = LZString.compressToBase64(JSON.stringify(page));
var body = LZString.compressToBase64(JSON.stringify(page))+EOF_MARKER;
if (! msgbase.save_msg(hdr,body)) {
log(LOG_ERROR,' ! Error saving frame: ['+this.name.toString()+']');
}
msgbase.close();
// @todo Find old message and delete it?
return true;
}