From 3bbdd4abae2601b551e58a0345a861d864b47bf3 Mon Sep 17 00:00:00 2001 From: Bryan Ashby Date: Tue, 5 Jul 2016 22:32:13 -0600 Subject: [PATCH] Check for MSGID explicitly during dupe check if present --- core/scanner_tossers/ftn_bso.js | 23 +++++++++++++++++++++-- 1 file changed, 21 insertions(+), 2 deletions(-) diff --git a/core/scanner_tossers/ftn_bso.js b/core/scanner_tossers/ftn_bso.js index b5e34985..0bc4621b 100644 --- a/core/scanner_tossers/ftn_bso.js +++ b/core/scanner_tossers/ftn_bso.js @@ -805,6 +805,24 @@ function FTNMessageScanTossModule() { callback(_.isString(localNetworkName) ? null : new Error('Packet destination is not us')); }, + function checkForDupeMSGID(callback) { + // + // If we have a MSGID, don't allow a dupe + // + if(!_.has(message.meta, 'FtnKludge.MSGID')) { + return callback(null); + } + + Message.getMessageIdsByMetaValue('FtnKludge', 'MSGID', message.meta.FtnKludge.MSGID, (err, msgIds) => { + if(msgIds && msgIds.length > 0) { + const err = new Error('Duplicate MSGID'); + err.code = 'DUPE_MSGID'; + return callback(err); + } + + return callback(null); + }); + }, function basicSetup(callback) { message.areaTag = localAreaTag; @@ -903,9 +921,10 @@ function FTNMessageScanTossModule() { // bump area fail stats importStats.areaFail[localAreaTag] = (importStats.areaFail[localAreaTag] || 0) + 1; - if('SQLITE_CONSTRAINT' === err.code) { + 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 }, + { area : localAreaTag, subject : message.subject, uuid : message.uuid, MSGID : msgId }, 'Not importing non-unique message'); return next(null);