Add a date to our imported messages. Tag our messages with an EOF marker
This commit is contained in:
parent
da51bd3d0b
commit
df1bad1c29
@ -423,16 +423,14 @@ function MsgArea() {
|
|||||||
|
|
||||||
try {
|
try {
|
||||||
if (msgbase.open()) {
|
if (msgbase.open()) {
|
||||||
var content = JSON.parse(LZString.decompressFromBase64(msgbase.get_msg_body(false,id,false,false,true,true)));
|
var raw = msgbase.get_msg_body(false,id,false,false,true,true);
|
||||||
msgbase.close();
|
|
||||||
|
|
||||||
var i;
|
// Our messages are terminated with \r=== EOF
|
||||||
for (var i=0; i<content.length; i++) {
|
if (! /^(.*)\r=== EOF/.test(raw))
|
||||||
// Echomail tag line
|
return undefined;
|
||||||
if (content[i] === '---' || content[i].substring(0,4) === '--- ')
|
|
||||||
break;
|
var content = JSON.parse(LZString.decompressFromBase64(raw.replace(/\r=== EOF[.\s\S]*$/,'')));
|
||||||
}
|
msgbase.close();
|
||||||
content.length = i;
|
|
||||||
|
|
||||||
} else {
|
} else {
|
||||||
writeln('*** NOPE WONT OPEN msgbase:'+JSON.stringify(msgbase));
|
writeln('*** NOPE WONT OPEN msgbase:'+JSON.stringify(msgbase));
|
||||||
|
15
load/page.js
15
load/page.js
@ -110,6 +110,8 @@ 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
|
||||||
@ -957,6 +959,7 @@ function Page(debug) {
|
|||||||
}
|
}
|
||||||
|
|
||||||
var contents = JSON.parse(f.read());
|
var contents = JSON.parse(f.read());
|
||||||
|
contents.date = f.date;
|
||||||
f.close();
|
f.close();
|
||||||
|
|
||||||
// Load the page content
|
// Load the page content
|
||||||
@ -1050,6 +1053,10 @@ function Page(debug) {
|
|||||||
log(LOG_DEBUG,'|- Loading frame: ['+page.toString()+'] from msgbase ['+msg.number+'] ['+SESSION_EXT+']');
|
log(LOG_DEBUG,'|- Loading frame: ['+page.toString()+'] from msgbase ['+msg.number+'] ['+SESSION_EXT+']');
|
||||||
|
|
||||||
var contents = mb.getContent(msg.number);
|
var contents = mb.getContent(msg.number);
|
||||||
|
|
||||||
|
if (contents === undefined)
|
||||||
|
return false;
|
||||||
|
|
||||||
contents.content = contents.content[SESSION_EXT];
|
contents.content = contents.content[SESSION_EXT];
|
||||||
|
|
||||||
return this.preload(contents,SESSION_EXT);
|
return this.preload(contents,SESSION_EXT);
|
||||||
@ -1249,11 +1256,11 @@ function Page(debug) {
|
|||||||
this.cost = contents.cost;
|
this.cost = contents.cost;
|
||||||
this.key = contents.key;
|
this.key = contents.key;
|
||||||
this.raw = contents.content;
|
this.raw = contents.content;
|
||||||
|
this.date = contents.date;
|
||||||
|
|
||||||
break;
|
break;
|
||||||
|
|
||||||
default:
|
default:
|
||||||
writeln('here');
|
|
||||||
log(LOG_ERROR,'|-! Unknown frame version : '+contents.version);
|
log(LOG_ERROR,'|-! Unknown frame version : '+contents.version);
|
||||||
this.get(new PageObject(FRAME_SYSTEM_ERROR));
|
this.get(new PageObject(FRAME_SYSTEM_ERROR));
|
||||||
return null;
|
return null;
|
||||||
@ -1288,7 +1295,7 @@ function Page(debug) {
|
|||||||
to: this.name,
|
to: this.name,
|
||||||
from: 'SYSTEM',
|
from: 'SYSTEM',
|
||||||
tags: this.name,
|
tags: this.name,
|
||||||
//date: msgs[x].date,
|
date: strftime("%a, %d %b %Y, %I:%M:%S %Z",this.date),
|
||||||
subject: 'Content',
|
subject: 'Content',
|
||||||
};
|
};
|
||||||
|
|
||||||
@ -1300,15 +1307,13 @@ function Page(debug) {
|
|||||||
'content': p.raw,
|
'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)) {
|
if (! msgbase.save_msg(hdr,body)) {
|
||||||
log(LOG_ERROR,' ! Error saving frame: ['+this.name.toString()+']');
|
log(LOG_ERROR,' ! Error saving frame: ['+this.name.toString()+']');
|
||||||
}
|
}
|
||||||
|
|
||||||
msgbase.close();
|
msgbase.close();
|
||||||
|
|
||||||
// @todo Find old message and delete it?
|
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user