From 1676c7336fb96b022f8b1772b3f234dd677eb5e9 Mon Sep 17 00:00:00 2001 From: Andris Reinman Date: Wed, 29 Jan 2020 15:38:15 +0200 Subject: [PATCH] do not read extra info for fetch --- imap-core/lib/commands/fetch.js | 13 ++++++++++--- lib/handlers/on-fetch.js | 12 +++++++++--- 2 files changed, 19 insertions(+), 6 deletions(-) diff --git a/imap-core/lib/commands/fetch.js b/imap-core/lib/commands/fetch.js index 96693ac4..16991941 100644 --- a/imap-core/lib/commands/fetch.js +++ b/imap-core/lib/commands/fetch.js @@ -50,9 +50,10 @@ module.exports = { let flagsExist = false; let uidExist = false; let modseqExist = false; - let bodystructureExist = true; - let rfc822sizeExist = true; - let envelopeExist = true; + let bodystructureExist = false; + let rfc822sizeExist = false; + let idateExist = false; + let envelopeExist = false; let markAsSeen = false; let metadataOnly = true; let changedSince = 0; @@ -130,6 +131,10 @@ module.exports = { envelopeExist = true; } + if (param.value.toUpperCase() === 'INTERNALDATE') { + idateExist = true; + } + if (!this.selected.readOnly) { if (param.value.toUpperCase() === 'BODY' && param.section) { // BODY[...] @@ -279,6 +284,8 @@ module.exports = { bodystructureExist, rfc822sizeExist, envelopeExist, + flagsExist, + idateExist, metadataOnly: !!metadataOnly, markAsSeen: !!markAsSeen, messages, diff --git a/lib/handlers/on-fetch.js b/lib/handlers/on-fetch.js index c6b31cca..7ce77b0d 100644 --- a/lib/handlers/on-fetch.js +++ b/lib/handlers/on-fetch.js @@ -53,11 +53,17 @@ module.exports = (server, messageHandler, userCache) => (mailbox, options, sessi let projection = { _id: true, uid: true, - modseq: true, - idate: true, - flags: true + modseq: true }; + if (options.flagsExist) { + projection.flags = true; + } + + if (options.idateExist) { + projection.idate = true; + } + if (options.bodystructureExist) { projection.bodystructure = true; }