debug the reason why the message did not match

This commit is contained in:
Girish Ramakrishnan 2016-06-24 12:21:29 -05:00
parent baa1dd5963
commit 1c08896f2d

View File

@ -129,14 +129,27 @@ function searchMessage(message, needle) {
assert.strictEqual(typeof message, 'object');
assert.strictEqual(typeof needle, 'object');
debug('searchMessage : %s %s %s %s', message.seqno, message.from[0], message.to[0], message.subject[0]);
var reason = [ ];
if (needle.subject && message.subject[0].match(needle.subject) === null) return false;
if (needle.body && message.body.match(needle.body) === null) return false;
if (needle.to && message.to[0].match(needle.to) === null) return false;
if (needle.from && message.from[0].match(needle.from) === null) return false;
if (needle.subject && message.subject[0].match(needle.subject) === null) {
reason.push('subject does not match');
}
return true;
if (needle.body && message.body.match(needle.body) === null) {
reason.push('body does not match');
}
if (needle.to && message.to[0].match(needle.to) === null) {
reason.push('to does not match');
}
if (needle.from && message.from[0].match(needle.from) === null) {
reason.push('from does not match');
}
debug('searchMessage : %s %s %s %s (%j)', message.seqno, message.from[0], message.to[0], message.subject[0], reason);
return reason.length === 0;
}
ImapProbe.prototype._scanBox = function (needle, callback) {