mirror of
https://github.com/node-red/node-red-nodes.git
synced 2023-10-10 13:36:58 +02:00
Email node - Catch bad IMAP folder error to close #495
This commit is contained in:
parent
c835fe7cad
commit
5f22603beb
@ -325,7 +325,16 @@ module.exports = function(RED) {
|
|||||||
imap.openBox(node.box, // Mailbox name
|
imap.openBox(node.box, // Mailbox name
|
||||||
false, // Open readonly?
|
false, // Open readonly?
|
||||||
function(err, box) {
|
function(err, box) {
|
||||||
|
//console.log("> Inbox err : %j", err);
|
||||||
//console.log("> Inbox open: %j", box);
|
//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) {
|
imap.search([ 'UNSEEN' ], function(err, results) {
|
||||||
if (err) {
|
if (err) {
|
||||||
node.status({fill:"red", shape:"ring", text:"email.status.foldererror"});
|
node.status({fill:"red", shape:"ring", text:"email.status.foldererror"});
|
||||||
@ -334,6 +343,7 @@ module.exports = function(RED) {
|
|||||||
setInputRepeatTimeout();
|
setInputRepeatTimeout();
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
else {
|
||||||
//console.log("> search - err=%j, results=%j", err, results);
|
//console.log("> search - err=%j, results=%j", err, results);
|
||||||
if (results.length === 0) {
|
if (results.length === 0) {
|
||||||
//console.log(" [X] - Nothing to fetch");
|
//console.log(" [X] - Nothing to fetch");
|
||||||
@ -394,7 +404,9 @@ module.exports = function(RED) {
|
|||||||
console.log('Fetch error: ' + err);
|
console.log('Fetch error: ' + err);
|
||||||
setInputRepeatTimeout();
|
setInputRepeatTimeout();
|
||||||
});
|
});
|
||||||
|
}
|
||||||
}); // End of imap->search
|
}); // End of imap->search
|
||||||
|
}
|
||||||
}); // End of imap->openInbox
|
}); // End of imap->openInbox
|
||||||
}); // End of imap->ready
|
}); // End of imap->ready
|
||||||
node.status({fill:"grey",shape:"dot",text:"node-red:common.status.connecting"});
|
node.status({fill:"grey",shape:"dot",text:"node-red:common.status.connecting"});
|
||||||
@ -441,8 +453,7 @@ module.exports = function(RED) {
|
|||||||
if (imap) { imap.destroy(); }
|
if (imap) { imap.destroy(); }
|
||||||
});
|
});
|
||||||
|
|
||||||
function setInputRepeatTimeout()
|
function setInputRepeatTimeout() {
|
||||||
{
|
|
||||||
// Set the repetition timer as needed
|
// Set the repetition timer as needed
|
||||||
if (!isNaN(node.repeat) && node.repeat > 0) {
|
if (!isNaN(node.repeat) && node.repeat > 0) {
|
||||||
node.interval_id = setTimeout( function() {
|
node.interval_id = setTimeout( function() {
|
||||||
|
@ -1,6 +1,6 @@
|
|||||||
{
|
{
|
||||||
"name": "node-red-node-email",
|
"name": "node-red-node-email",
|
||||||
"version": "1.0.5",
|
"version": "1.0.6",
|
||||||
"description": "Node-RED nodes to send and receive simple emails",
|
"description": "Node-RED nodes to send and receive simple emails",
|
||||||
"dependencies": {
|
"dependencies": {
|
||||||
"imap": "^0.8.19",
|
"imap": "^0.8.19",
|
||||||
|
Loading…
Reference in New Issue
Block a user