From 2965e3f8899e638b7e0c6818a7fe6fcc7761d109 Mon Sep 17 00:00:00 2001 From: Robin Qu Date: Wed, 22 Aug 2012 10:08:43 +0800 Subject: [PATCH] support find uid by multiple seqno --- lib/imap.utilities.js | 6 ++++-- test/test-seqno-serach.js | 20 ++++++++++++++++++++ 2 files changed, 24 insertions(+), 2 deletions(-) create mode 100644 test/test-seqno-serach.js diff --git a/lib/imap.utilities.js b/lib/imap.utilities.js index ff51f56..2e7043e 100644 --- a/lib/imap.utilities.js +++ b/lib/imap.utilities.js @@ -368,8 +368,9 @@ exports.buildSearchQuery = function(options, extensions, isOrChild) { try { // last hope it's a seqno set // http://tools.ietf.org/html/rfc3501#section-6.4.4 - exports.validateUIDList([criteria]); - searchargs += modifier + criteria; + var seqnos = (args ? [criteria].concat(args) : [criteria]); + exports.validateUIDList([seqnos]); + searchargs += modifier + seqnos.join(','); } catch(e) { throw new Error('Unexpected search option: ' + criteria); } @@ -378,6 +379,7 @@ exports.buildSearchQuery = function(options, extensions, isOrChild) { if (isOrChild) break; } + console.log(searchargs); return searchargs; } diff --git a/test/test-seqno-serach.js b/test/test-seqno-serach.js new file mode 100644 index 0000000..e21bed8 --- /dev/null +++ b/test/test-seqno-serach.js @@ -0,0 +1,20 @@ +var ImapConnection = require("../lib/imap").ImapConnection, + imap = new ImapConnection({ + username: "pingkitnet@gmail.com", + password: "ping5555566666", + host: "imap.gmail.com", + port: 993, + secure: true + }); + + +imap.connect(function() { + imap.openBox('INBOX', false, function() { + //find uid by seqno + imap.search([["1:5", "8:10"]], function(e, results) { + console.log(e, results); + imap.logout(); + }); + }) +}); +