Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

make OR filter work #444

Open
wants to merge 2 commits into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 2 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -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, [email protected], [email protected], and Ted Johnson:
['UNSEEN', ['SMALLER','5000'], 'OR', ['OR', ['FROM','Paul Smith'],['FROM','[email protected]']],['OR', ['FROM','[email protected]'],['FROM','Ted Johnson']]]

`callback` has 2 parameters: < _Error_ >err, < _array_ >UIDs.

Expand Down
3 changes: 2 additions & 1 deletion lib/Connection.js
Original file line number Diff line number Diff line change
Expand Up @@ -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();
Expand All @@ -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 ';
Expand Down