node-imap icon indicating copy to clipboard operation
node-imap copied to clipboard

In fetch criteria, ORs cannot be nested

Open zzmp opened this issue 11 years ago • 4 comments

Example: Fetching mail from a list of addresses, where FROM can be [email protected], [email protected], [email protected].

Entering this as ['OR', ['[email protected]', '[email protected]', '[email protected]']] fails, as OR can only take two arguments. Entering this as nested OR also fails in parsing it to a criterion string.

Is there another way to include ORed lists?

zzmp avatar Jan 12 '15 19:01 zzmp

faced the same issue and implemented a workaround as follows:

@@ -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(1)),
         modifier = (isOrChild ? '' : ' ');
     if (typeof criteria === 'string')
       criteria = criteria.toUpperCase();

Setogit avatar Jan 20 '15 02:01 Setogit

aha, sorry.

  •    args = (isOrChild ? null : options.slice(I+1)),
    

Setogit avatar Jan 20 '15 04:01 Setogit

@Setogit Why not PR this?

zzmp avatar Jan 20 '15 23:01 zzmp

Absolutely. Pull requested as make OR filter work #444

Setogit avatar Jan 21 '15 00:01 Setogit