Merge pull request #327 from NuSkooler/313-rescan-date-time-issues

Fix issues with message timestamps
This commit is contained in:
Bryan Ashby 2020-11-17 19:09:59 -07:00 committed by GitHub
commit 51c9c7dc2d
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
2 changed files with 24 additions and 8 deletions

View File

@ -678,11 +678,28 @@ function Packet(options) {
}
//
// If we have a UTC offset kludge (e.g. TZUTC) then update
// modDateTime with it
// Attempt to handle FTN time zone kludges of 'TZUTC' and
// 'TZUTCINFO'.
//
if(_.isString(msg.meta.FtnKludge.TZUTC) && msg.meta.FtnKludge.TZUTC.length > 0) {
msg.modDateTime = msg.modTimestamp.utcOffset(msg.meta.FtnKludge.TZUTC);
// See http://ftsc.org/docs/frl-1004.002
//
const tzKludge = msg.meta.FtnKludge.TZUTC || msg.meta.FtnKludge.TZUTCINFO;
const tzMatch = /([+-]?)([0-9]{2})([0-9]{2})/.exec(tzKludge);
if (tzMatch) {
//
// - Both kludges should provide a offset in hhmm format
// - Negative offsets must proceed with '-'
// - Positive offsets must not (to spec) proceed with '+', but
// we'll allow it.
//
const [, sign, hours, minutes ] = tzMatch;
// convert to a [+|-]hh:mm format.
// example: 1300 -> +13:00
const utcOffset = `${sign||'+'}${hours}:${minutes}`;
// finally, update our modTimestamp
msg.modTimestamp = msg.modTimestamp.utcOffset(utcOffset);
}
// :TODO: Parser should give is this info:

View File

@ -134,7 +134,7 @@ module.exports = class Message {
modTimestamp = moment(modTimestamp);
}
this.modTimestamp = modTimestamp;
this.modTimestamp = modTimestamp || moment();
this.meta = {};
_.defaultsDeep(this.meta, { System : {} }, meta);
@ -695,11 +695,10 @@ module.exports = class Message {
},
function storeMessage(trans, callback) {
// generate a UUID for this message if required (general case)
const msgTimestamp = moment();
if(!self.messageUuid) {
self.messageUuid = Message.createMessageUUID(
self.areaTag,
msgTimestamp,
self.modTimestamp,
self.subject,
self.message
);
@ -710,7 +709,7 @@ module.exports = class Message {
VALUES (?, ?, ?, ?, ?, ?, ?, ?);`,
[
self.areaTag, self.messageUuid, self.replyToMsgId, self.toUserName,
self.fromUserName, self.subject, self.message, getISOTimestampString(msgTimestamp)
self.fromUserName, self.subject, self.message, getISOTimestampString(self.modTimestamp)
],
function inserted(err) { // use non-arrow function for 'this' scope
if(!err) {