From f74f257932cf7f8db1f8714b0afa5670c837175d Mon Sep 17 00:00:00 2001 From: Matthias Biggeleben Date: Fri, 19 Feb 2016 16:49:29 +0100 Subject: [PATCH] Connection: allow custom metadata to be fetched --- README.md | 1 + lib/Connection.js | 5 +++++ 2 files changed, 6 insertions(+) diff --git a/README.md b/README.md index 12b6ce4..5d2d538 100644 --- a/README.md +++ b/README.md @@ -576,6 +576,7 @@ Connection Instance Methods * **envelope** - _boolean_ - Fetch the message envelope. **Default:** false * **size** - _boolean_ - Fetch the RFC822 size. **Default:** false * **modifiers** - _object_ - Fetch modifiers defined by IMAP extensions. **Default:** (none) + * **extensions** - _array_ - Fetch custom fields defined by IMAP extensions, e.g. ['X-MAILBOX', 'X-REAL-UID']. **Default:** (none) * **bodies** - _mixed_ - A string or Array of strings containing the body part section to fetch. **Default:** (none) Example sections: * 'HEADER' - The message header diff --git a/lib/Connection.js b/lib/Connection.js index c6c4149..b2964a3 100644 --- a/lib/Connection.js +++ b/lib/Connection.js @@ -815,6 +815,11 @@ Connection.prototype._fetch = function(which, uids, options) { fetching.push('BODYSTRUCTURE'); if (options.size) fetching.push('RFC822.SIZE'); + if (Array.isArray(options.extensions)) { + options.extensions.forEach(function (extension) { + fetching.push(extension.toUpperCase()); + }); + } cmd += fetching.join(' '); if (options.bodies !== undefined) { var bodies = options.bodies,