From 392fbb1b3f2adbcbfb932c624699b9f1e7a62d83 Mon Sep 17 00:00:00 2001 From: Setogit Date: Tue, 20 Jan 2015 15:44:25 -0800 Subject: [PATCH 1/2] make OR filter work --- lib/Connection.js | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/lib/Connection.js b/lib/Connection.js index eee5cbbd..a635059c 100644 --- a/lib/Connection.js +++ b/lib/Connection.js @@ -1830,7 +1830,7 @@ function buildSearchQuery(options, extensions, info, isOrChild) { var searchargs = '', err, val; for (var i = 0, len = options.length; i < len; ++i) { var criteria = (isOrChild ? options : options[i]), - args = null, + args = (isOrChild ? null : options.slice(i+1)), modifier = (isOrChild ? '' : ' '); if (typeof criteria === 'string') criteria = criteria.toUpperCase(); @@ -1853,6 +1853,7 @@ function buildSearchQuery(options, extensions, info, isOrChild) { searchargs += ') ('; searchargs += buildSearchQuery(args[1], extensions, info, true); searchargs += ')'; + i = i+2 } else { if (criteria[0] === '!') { modifier += 'NOT '; From cddb41e0e9c3050b068c4e8924a01cf27071d2ae Mon Sep 17 00:00:00 2001 From: Setogit Date: Tue, 20 Jan 2015 17:42:59 -0800 Subject: [PATCH 2/2] add criteria example for OR --- README.md | 2 ++ 1 file changed, 2 insertions(+) diff --git a/README.md b/README.md index 12b6ce42..175222e8 100644 --- a/README.md +++ b/README.md @@ -564,6 +564,8 @@ Connection Instance Methods * Messages that are EITHER unread OR are dated April 20, 2010 or later, you could use: [ ['OR', 'UNSEEN', ['SINCE', 'April 20, 2010'] ] ] * All messages that have 'node-imap' in the subject header: [ ['HEADER', 'SUBJECT', 'node-imap'] ] * All messages that _do not_ have 'node-imap' in the subject header: [ ['!HEADER', 'SUBJECT', 'node-imap'] ] + * All UNSEEN messages smaller than 5,000 bytes from one of four senders: Paul Smith, david@example.com, mary@example.com, and Ted Johnson: + ['UNSEEN', ['SMALLER','5000'], 'OR', ['OR', ['FROM','Paul Smith'],['FROM','david@example.com']],['OR', ['FROM','mary@example.com'],['FROM','Ted Johnson']]] `callback` has 2 parameters: < _Error_ >err, < _array_ >UIDs.