Fix Message.uuid vs Message.messageUuid
* Just use Message.messageUuid which better aligns with message_uuid in DB, messageId, etc. * Keep uuid as property for now just in case
This commit is contained in:
parent
b7cac2d38f
commit
60955cac11
|
@ -107,15 +107,23 @@ const MESSAGE_ROW_MAP = {
|
||||||
module.exports = class Message {
|
module.exports = class Message {
|
||||||
constructor(
|
constructor(
|
||||||
{
|
{
|
||||||
messageId = 0, areaTag = Message.WellKnownAreaTags.Invalid, uuid, replyToMsgId = 0,
|
messageId = 0,
|
||||||
toUserName = '', fromUserName = '', subject = '', message = '', modTimestamp = moment(),
|
areaTag = Message.WellKnownAreaTags.Invalid,
|
||||||
meta, hashTags = [],
|
uuid,
|
||||||
|
replyToMsgId = 0,
|
||||||
|
toUserName = '',
|
||||||
|
fromUserName = '',
|
||||||
|
subject = '',
|
||||||
|
message = '',
|
||||||
|
modTimestamp = moment(),
|
||||||
|
meta,
|
||||||
|
hashTags = [],
|
||||||
} = { }
|
} = { }
|
||||||
)
|
)
|
||||||
{
|
{
|
||||||
this.messageId = messageId;
|
this.messageId = messageId;
|
||||||
this.areaTag = areaTag;
|
this.areaTag = areaTag;
|
||||||
this.uuid = uuid;
|
this.messageUuid = uuid;
|
||||||
this.replyToMsgId = replyToMsgId;
|
this.replyToMsgId = replyToMsgId;
|
||||||
this.toUserName = toUserName;
|
this.toUserName = toUserName;
|
||||||
this.fromUserName = fromUserName;
|
this.fromUserName = fromUserName;
|
||||||
|
@ -134,6 +142,10 @@ module.exports = class Message {
|
||||||
this.hashTags = hashTags;
|
this.hashTags = hashTags;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
get uuid() { // deprecated, will be removed in the near future
|
||||||
|
return this.messageUuid;
|
||||||
|
}
|
||||||
|
|
||||||
isValid() { return true; } // :TODO: obviously useless; look into this or remove it
|
isValid() { return true; } // :TODO: obviously useless; look into this or remove it
|
||||||
|
|
||||||
static isPrivateAreaTag(areaTag) {
|
static isPrivateAreaTag(areaTag) {
|
||||||
|
@ -684,8 +696,8 @@ module.exports = class Message {
|
||||||
function storeMessage(trans, callback) {
|
function storeMessage(trans, callback) {
|
||||||
// generate a UUID for this message if required (general case)
|
// generate a UUID for this message if required (general case)
|
||||||
const msgTimestamp = moment();
|
const msgTimestamp = moment();
|
||||||
if(!self.uuid) {
|
if(!self.messageUuid) {
|
||||||
self.uuid = Message.createMessageUUID(
|
self.messageUuid = Message.createMessageUUID(
|
||||||
self.areaTag,
|
self.areaTag,
|
||||||
msgTimestamp,
|
msgTimestamp,
|
||||||
self.subject,
|
self.subject,
|
||||||
|
@ -696,7 +708,10 @@ module.exports = class Message {
|
||||||
trans.run(
|
trans.run(
|
||||||
`INSERT INTO message (area_tag, message_uuid, reply_to_message_id, to_user_name, from_user_name, subject, message, modified_timestamp)
|
`INSERT INTO message (area_tag, message_uuid, reply_to_message_id, to_user_name, from_user_name, subject, message, modified_timestamp)
|
||||||
VALUES (?, ?, ?, ?, ?, ?, ?, ?);`,
|
VALUES (?, ?, ?, ?, ?, ?, ?, ?);`,
|
||||||
[ self.areaTag, self.uuid, self.replyToMsgId, self.toUserName, self.fromUserName, self.subject, self.message, getISOTimestampString(msgTimestamp) ],
|
[
|
||||||
|
self.areaTag, self.messageUuid, self.replyToMsgId, self.toUserName,
|
||||||
|
self.fromUserName, self.subject, self.message, getISOTimestampString(msgTimestamp)
|
||||||
|
],
|
||||||
function inserted(err) { // use non-arrow function for 'this' scope
|
function inserted(err) { // use non-arrow function for 'this' scope
|
||||||
if(!err) {
|
if(!err) {
|
||||||
self.messageId = this.lastID;
|
self.messageId = this.lastID;
|
||||||
|
|
|
@ -50,7 +50,7 @@ exports.getModule = class AreaPostFSEModule extends FullScreenEditorModule {
|
||||||
} else {
|
} else {
|
||||||
// note: not logging 'from' here as it's part of client.log.xxxx()
|
// note: not logging 'from' here as it's part of client.log.xxxx()
|
||||||
self.client.log.info(
|
self.client.log.info(
|
||||||
{ to : msg.toUserName, subject : msg.subject, uuid : msg.uuid },
|
{ to : msg.toUserName, subject : msg.subject, uuid : msg.messageUuid },
|
||||||
'Message persisted'
|
'Message persisted'
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
|
|
@ -1491,7 +1491,7 @@ class QWKPacketWriter extends EventEmitter {
|
||||||
Conference : message.isPrivate() ? '0' : getMessageConfTagByAreaTag(message.areaTag),
|
Conference : message.isPrivate() ? '0' : getMessageConfTagByAreaTag(message.areaTag),
|
||||||
|
|
||||||
// ENiGMA Headers
|
// ENiGMA Headers
|
||||||
MessageUUID : message.uuid,
|
MessageUUID : message.messageUuid,
|
||||||
ModTimestamp : message.modTimestamp.format('YYYY-MM-DDTHH:mm:ss.SSSZ'),
|
ModTimestamp : message.modTimestamp.format('YYYY-MM-DDTHH:mm:ss.SSSZ'),
|
||||||
AreaTag : message.areaTag,
|
AreaTag : message.areaTag,
|
||||||
};
|
};
|
||||||
|
|
|
@ -1215,7 +1215,7 @@ function FTNMessageScanTossModule() {
|
||||||
//
|
//
|
||||||
if(true === _.get(Config(), [ 'messageNetworks', 'ftn', 'areas', config.localAreaTag, 'allowDupes' ], false)) {
|
if(true === _.get(Config(), [ 'messageNetworks', 'ftn', 'areas', config.localAreaTag, 'allowDupes' ], false)) {
|
||||||
// just generate a UUID & therefor always allow for dupes
|
// just generate a UUID & therefor always allow for dupes
|
||||||
message.uuid = uuidV4();
|
message.messageUuid = uuidV4();
|
||||||
}
|
}
|
||||||
|
|
||||||
return callback(null);
|
return callback(null);
|
||||||
|
@ -1378,7 +1378,7 @@ function FTNMessageScanTossModule() {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
message.uuid = Message.createMessageUUID(
|
message.messageUuid = Message.createMessageUUID(
|
||||||
localAreaTag,
|
localAreaTag,
|
||||||
message.modTimestamp,
|
message.modTimestamp,
|
||||||
message.subject,
|
message.subject,
|
||||||
|
@ -1398,7 +1398,7 @@ function FTNMessageScanTossModule() {
|
||||||
if('SQLITE_CONSTRAINT' === err.code || 'DUPE_MSGID' === err.code) {
|
if('SQLITE_CONSTRAINT' === err.code || 'DUPE_MSGID' === err.code) {
|
||||||
const msgId = _.has(message.meta, 'FtnKludge.MSGID') ? message.meta.FtnKludge.MSGID : 'N/A';
|
const msgId = _.has(message.meta, 'FtnKludge.MSGID') ? message.meta.FtnKludge.MSGID : 'N/A';
|
||||||
Log.info(
|
Log.info(
|
||||||
{ area : localAreaTag, subject : message.subject, uuid : message.uuid, MSGID : msgId },
|
{ area : localAreaTag, subject : message.subject, uuid : message.messageUuid, MSGID : msgId },
|
||||||
'Not importing non-unique message');
|
'Not importing non-unique message');
|
||||||
|
|
||||||
return next(null);
|
return next(null);
|
||||||
|
@ -2349,7 +2349,7 @@ FTNMessageScanTossModule.prototype.record = function(message) {
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
const info = { uuid : message.uuid, subject : message.subject };
|
const info = { uuid : message.messageUuid, subject : message.subject };
|
||||||
|
|
||||||
function exportLog(err) {
|
function exportLog(err) {
|
||||||
if(err) {
|
if(err) {
|
||||||
|
@ -2363,7 +2363,7 @@ FTNMessageScanTossModule.prototype.record = function(message) {
|
||||||
Object.assign(info, { type : 'NetMail' } );
|
Object.assign(info, { type : 'NetMail' } );
|
||||||
|
|
||||||
if(this.exportingStart()) {
|
if(this.exportingStart()) {
|
||||||
this.exportNetMailMessagesToUplinks( [ message.uuid ], err => {
|
this.exportNetMailMessagesToUplinks( [ message.messageUuid ], err => {
|
||||||
this.exportingEnd( () => exportLog(err) );
|
this.exportingEnd( () => exportLog(err) );
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
@ -2376,7 +2376,7 @@ FTNMessageScanTossModule.prototype.record = function(message) {
|
||||||
}
|
}
|
||||||
|
|
||||||
if(this.exportingStart()) {
|
if(this.exportingStart()) {
|
||||||
this.exportEchoMailMessagesToUplinks( [ message.uuid ], areaConfig, err => {
|
this.exportEchoMailMessagesToUplinks( [ message.messageUuid ], areaConfig, err => {
|
||||||
this.exportingEnd( () => exportLog(err) );
|
this.exportingEnd( () => exportLog(err) );
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in New Issue