Email node - Catch bad IMAP folder error to close #495

This commit is contained in:
Dave Conway-Jones 2018-10-26 17:00:27 +01:00
parent c835fe7cad
commit 5f22603beb
No known key found for this signature in database
GPG Key ID: 9E7F9C73F5168CD4
2 changed files with 80 additions and 69 deletions

View File

@ -325,7 +325,16 @@ module.exports = function(RED) {
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) {
node.status({fill:"red", shape:"ring", text:"email.status.foldererror"});
node.error(RED._("email.errors.fetchfail", {folder:node.box}),err);
imap.end();
setInputRepeatTimeout();
return;
}
else {
imap.search([ 'UNSEEN' ], function(err, results) {
if (err) {
node.status({fill:"red", shape:"ring", text:"email.status.foldererror"});
@ -334,6 +343,7 @@ module.exports = function(RED) {
setInputRepeatTimeout();
return;
}
else {
//console.log("> search - err=%j, results=%j", err, results);
if (results.length === 0) {
//console.log(" [X] - Nothing to fetch");
@ -394,7 +404,9 @@ module.exports = function(RED) {
console.log('Fetch error: ' + err);
setInputRepeatTimeout();
});
}
}); // End of imap->search
}
}); // End of imap->openInbox
}); // End of imap->ready
node.status({fill:"grey",shape:"dot",text:"node-red:common.status.connecting"});
@ -441,8 +453,7 @@ module.exports = function(RED) {
if (imap) { imap.destroy(); }
});
function setInputRepeatTimeout()
{
function setInputRepeatTimeout() {
// Set the repetition timer as needed
if (!isNaN(node.repeat) && node.repeat > 0) {
node.interval_id = setTimeout( function() {

View File

@ -1,6 +1,6 @@
{
"name": "node-red-node-email",
"version": "1.0.5",
"version": "1.0.6",
"description": "Node-RED nodes to send and receive simple emails",
"dependencies": {
"imap": "^0.8.19",