email - show valid folders in error if fetch fails

This commit is contained in:
Dave Conway-Jones 2020-09-23 23:54:09 +01:00
parent 973fd8c6ec
commit d3a3bc158c
No known key found for this signature in database
GPG Key ID: 302A6725C594817F
2 changed files with 15 additions and 3 deletions

View File

@ -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();

View File

@ -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",