From 86b399238a84a36fe1890111d8c5e4a38c6e8609 Mon Sep 17 00:00:00 2001 From: Chotiwat Chawannakul Date: Mon, 17 Sep 2012 11:50:34 +0700 Subject: [PATCH 1/2] Can request for message size when fetch. --- lib/imap.js | 5 ++++- lib/imap.parsers.js | 2 ++ 2 files changed, 6 insertions(+), 1 deletion(-) diff --git a/lib/imap.js b/lib/imap.js index 0ad3893..755c9f9 100644 --- a/lib/imap.js +++ b/lib/imap.js @@ -862,7 +862,10 @@ ImapConnection.prototype._fetch = function(which, uids, options) { if (extensions) cmd += extensions; cmd += 'UID FLAGS INTERNALDATE'; - cmd += (opts.request.struct ? ' BODYSTRUCTURE' : ''); + if(opts.request.struct) + cmd += ' BODYSTRUCTURE'; + if(opts.request.size) + cmd += ' RFC822.SIZE'; if (toFetch !== undefined) { cmd += ' BODY'; if (!opts.markSeen) diff --git a/lib/imap.parsers.js b/lib/imap.parsers.js index 2af3d2a..16f4f1a 100644 --- a/lib/imap.parsers.js +++ b/lib/imap.parsers.js @@ -59,6 +59,8 @@ exports.parseFetch = function(str, literals, fetchData) { fetchData.flags = result[i+1].filter(utils.isNotEmpty); else if (result[i] === 'BODYSTRUCTURE') fetchData.structure = exports.parseBodyStructure(result[i+1], literals); + else if (result[i] === 'RFC822.SIZE') + fetchData.size = parseInt(result[i+1], 10); else if (typeof result[i] === 'string') // simple extensions fetchData[result[i].toLowerCase()] = result[i+1]; } From 2615008ec6c24eb354d3c12db005289730bd6384 Mon Sep 17 00:00:00 2001 From: Chotiwat Chawannakul Date: Fri, 19 Oct 2012 13:56:59 +0700 Subject: [PATCH 2/2] Fix style --- lib/imap.js | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/lib/imap.js b/lib/imap.js index 755c9f9..c8efca0 100644 --- a/lib/imap.js +++ b/lib/imap.js @@ -862,9 +862,9 @@ ImapConnection.prototype._fetch = function(which, uids, options) { if (extensions) cmd += extensions; cmd += 'UID FLAGS INTERNALDATE'; - if(opts.request.struct) + if (opts.request.struct) cmd += ' BODYSTRUCTURE'; - if(opts.request.size) + if (opts.request.size) cmd += ' RFC822.SIZE'; if (toFetch !== undefined) { cmd += ' BODY';