Check for MSGID explicitly during dupe check if present

This commit is contained in:
Bryan Ashby 2016-07-05 22:32:13 -06:00
parent f87e9917a0
commit 3bbdd4abae
1 changed files with 21 additions and 2 deletions

View File

@ -805,6 +805,24 @@ function FTNMessageScanTossModule() {
callback(_.isString(localNetworkName) ? null : new Error('Packet destination is not us')); 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) { function basicSetup(callback) {
message.areaTag = localAreaTag; message.areaTag = localAreaTag;
@ -903,9 +921,10 @@ function FTNMessageScanTossModule() {
// bump area fail stats // bump area fail stats
importStats.areaFail[localAreaTag] = (importStats.areaFail[localAreaTag] || 0) + 1; 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( 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'); 'Not importing non-unique message');
return next(null); return next(null);