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 {
|
||||
constructor(
|
||||
{
|
||||
messageId = 0, areaTag = Message.WellKnownAreaTags.Invalid, uuid, replyToMsgId = 0,
|
||||
toUserName = '', fromUserName = '', subject = '', message = '', modTimestamp = moment(),
|
||||
meta, hashTags = [],
|
||||
messageId = 0,
|
||||
areaTag = Message.WellKnownAreaTags.Invalid,
|
||||
uuid,
|
||||
replyToMsgId = 0,
|
||||
toUserName = '',
|
||||
fromUserName = '',
|
||||
subject = '',
|
||||
message = '',
|
||||
modTimestamp = moment(),
|
||||
meta,
|
||||
hashTags = [],
|
||||
} = { }
|
||||
)
|
||||
{
|
||||
this.messageId = messageId;
|
||||
this.areaTag = areaTag;
|
||||
this.uuid = uuid;
|
||||
this.messageUuid = uuid;
|
||||
this.replyToMsgId = replyToMsgId;
|
||||
this.toUserName = toUserName;
|
||||
this.fromUserName = fromUserName;
|
||||
|
@ -134,6 +142,10 @@ module.exports = class Message {
|
|||
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
|
||||
|
||||
static isPrivateAreaTag(areaTag) {
|
||||
|
@ -684,8 +696,8 @@ module.exports = class Message {
|
|||
function storeMessage(trans, callback) {
|
||||
// generate a UUID for this message if required (general case)
|
||||
const msgTimestamp = moment();
|
||||
if(!self.uuid) {
|
||||
self.uuid = Message.createMessageUUID(
|
||||
if(!self.messageUuid) {
|
||||
self.messageUuid = Message.createMessageUUID(
|
||||
self.areaTag,
|
||||
msgTimestamp,
|
||||
self.subject,
|
||||
|
@ -696,7 +708,10 @@ module.exports = class Message {
|
|||
trans.run(
|
||||
`INSERT INTO message (area_tag, message_uuid, reply_to_message_id, to_user_name, from_user_name, subject, message, modified_timestamp)
|
||||
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
|
||||
if(!err) {
|
||||
self.messageId = this.lastID;
|
||||
|
|
|
@ -50,7 +50,7 @@ exports.getModule = class AreaPostFSEModule extends FullScreenEditorModule {
|
|||
} else {
|
||||
// note: not logging 'from' here as it's part of client.log.xxxx()
|
||||
self.client.log.info(
|
||||
{ to : msg.toUserName, subject : msg.subject, uuid : msg.uuid },
|
||||
{ to : msg.toUserName, subject : msg.subject, uuid : msg.messageUuid },
|
||||
'Message persisted'
|
||||
);
|
||||
}
|
||||
|
|
|
@ -1491,7 +1491,7 @@ class QWKPacketWriter extends EventEmitter {
|
|||
Conference : message.isPrivate() ? '0' : getMessageConfTagByAreaTag(message.areaTag),
|
||||
|
||||
// ENiGMA Headers
|
||||
MessageUUID : message.uuid,
|
||||
MessageUUID : message.messageUuid,
|
||||
ModTimestamp : message.modTimestamp.format('YYYY-MM-DDTHH:mm:ss.SSSZ'),
|
||||
AreaTag : message.areaTag,
|
||||
};
|
||||
|
|
|
@ -1215,7 +1215,7 @@ function FTNMessageScanTossModule() {
|
|||
//
|
||||
if(true === _.get(Config(), [ 'messageNetworks', 'ftn', 'areas', config.localAreaTag, 'allowDupes' ], false)) {
|
||||
// just generate a UUID & therefor always allow for dupes
|
||||
message.uuid = uuidV4();
|
||||
message.messageUuid = uuidV4();
|
||||
}
|
||||
|
||||
return callback(null);
|
||||
|
@ -1378,7 +1378,7 @@ function FTNMessageScanTossModule() {
|
|||
}
|
||||
}
|
||||
|
||||
message.uuid = Message.createMessageUUID(
|
||||
message.messageUuid = Message.createMessageUUID(
|
||||
localAreaTag,
|
||||
message.modTimestamp,
|
||||
message.subject,
|
||||
|
@ -1398,7 +1398,7 @@ function FTNMessageScanTossModule() {
|
|||
if('SQLITE_CONSTRAINT' === err.code || 'DUPE_MSGID' === err.code) {
|
||||
const msgId = _.has(message.meta, 'FtnKludge.MSGID') ? message.meta.FtnKludge.MSGID : 'N/A';
|
||||
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');
|
||||
|
||||
return next(null);
|
||||
|
@ -2349,7 +2349,7 @@ FTNMessageScanTossModule.prototype.record = function(message) {
|
|||
return;
|
||||
}
|
||||
|
||||
const info = { uuid : message.uuid, subject : message.subject };
|
||||
const info = { uuid : message.messageUuid, subject : message.subject };
|
||||
|
||||
function exportLog(err) {
|
||||
if(err) {
|
||||
|
@ -2363,7 +2363,7 @@ FTNMessageScanTossModule.prototype.record = function(message) {
|
|||
Object.assign(info, { type : 'NetMail' } );
|
||||
|
||||
if(this.exportingStart()) {
|
||||
this.exportNetMailMessagesToUplinks( [ message.uuid ], err => {
|
||||
this.exportNetMailMessagesToUplinks( [ message.messageUuid ], err => {
|
||||
this.exportingEnd( () => exportLog(err) );
|
||||
});
|
||||
}
|
||||
|
@ -2376,7 +2376,7 @@ FTNMessageScanTossModule.prototype.record = function(message) {
|
|||
}
|
||||
|
||||
if(this.exportingStart()) {
|
||||
this.exportEchoMailMessagesToUplinks( [ message.uuid ], areaConfig, err => {
|
||||
this.exportEchoMailMessagesToUplinks( [ message.messageUuid ], areaConfig, err => {
|
||||
this.exportingEnd( () => exportLog(err) );
|
||||
});
|
||||
}
|
||||
|
|
Loading…
Reference in New Issue