From d3a3bc158cd1237867f92b02b523206e2c2a686d Mon Sep 17 00:00:00 2001 From: Dave Conway-Jones Date: Wed, 23 Sep 2020 23:54:09 +0100 Subject: [PATCH] email - show valid folders in error if fetch fails --- social/email/61-email.js | 16 ++++++++++++++-- social/email/package.json | 2 +- 2 files changed, 15 insertions(+), 3 deletions(-) diff --git a/social/email/61-email.js b/social/email/61-email.js index f1f61f9e..4efaf2a3 100644 --- a/social/email/61-email.js +++ b/social/email/61-email.js @@ -341,15 +341,27 @@ module.exports = function(RED) { ss = true; node.status({fill:"blue", shape:"dot", text:"email.status.fetching"}); //console.log("> ready"); - // Open the inbox folder + // Open the folder imap.openBox(node.box, // Mailbox name false, // Open readonly? function(err, box) { //console.log("> Inbox err : %j", err); //console.log("> Inbox open: %j", box); if (err) { + var boxs = []; + imap.getBoxes(function(err,boxes) { + if (err) { return; } + for (var prop in boxes) { + if (boxes.hasOwnProperty(prop)) { + if (boxes[prop].children) { + boxs.push(prop+"/{"+Object.keys(boxes[prop].children)+'}'); + } + else { boxs.push(prop); } + } + } + node.error(RED._("email.errors.fetchfail", {folder:node.box+". Folders - "+boxs.join(', ')}),err); + }); node.status({fill:"red", shape:"ring", text:"email.status.foldererror"}); - node.error(RED._("email.errors.fetchfail", {folder:node.box}),err); imap.end(); s = false; setInputRepeatTimeout(); diff --git a/social/email/package.json b/social/email/package.json index 211462ec..45d3bcbd 100644 --- a/social/email/package.json +++ b/social/email/package.json @@ -1,6 +1,6 @@ { "name": "node-red-node-email", - "version": "1.7.10", + "version": "1.7.11", "description": "Node-RED nodes to send and receive simple emails", "dependencies": { "imap": "^0.8.19",