mirror of
https://github.com/node-red/node-red.git
synced 2023-10-10 13:36:53 +02:00
Catch bad folder error in email node
This commit is contained in:
parent
8dc98420db
commit
269846c587
@ -175,6 +175,11 @@ module.exports = function(RED) {
|
|||||||
node.status({fill:"blue",shape:"dot",text:"fetching"});
|
node.status({fill:"blue",shape:"dot",text:"fetching"});
|
||||||
var pay = {};
|
var pay = {};
|
||||||
imap.openBox(node.box, false, function(err, box) {
|
imap.openBox(node.box, false, function(err, box) {
|
||||||
|
if (err) {
|
||||||
|
node.status({fill:"red",shape:"ring",text:"fetch folder error"});
|
||||||
|
node.error("Failed to fetch folder "+node.box,err);
|
||||||
|
}
|
||||||
|
else {
|
||||||
if (box.messages.total > 0) {
|
if (box.messages.total > 0) {
|
||||||
var f = imap.seq.fetch(box.messages.total + ':*', { markSeen:true, bodies: ['HEADER.FIELDS (FROM SUBJECT DATE TO CC BCC)','TEXT'] });
|
var f = imap.seq.fetch(box.messages.total + ':*', { markSeen:true, bodies: ['HEADER.FIELDS (FROM SUBJECT DATE TO CC BCC)','TEXT'] });
|
||||||
f.on('message', function(msg, seqno) {
|
f.on('message', function(msg, seqno) {
|
||||||
@ -216,8 +221,8 @@ module.exports = function(RED) {
|
|||||||
});
|
});
|
||||||
});
|
});
|
||||||
f.on('error', function(err) {
|
f.on('error', function(err) {
|
||||||
node.warn('fetch error: ' + err);
|
node.warn('fetch message error: ' + err);
|
||||||
node.status({fill:"red",shape:"ring",text:"fetch error"});
|
node.status({fill:"red",shape:"ring",text:"fetch message error"});
|
||||||
});
|
});
|
||||||
f.on('end', function() {
|
f.on('end', function() {
|
||||||
delete(pay._msgid);
|
delete(pay._msgid);
|
||||||
@ -229,15 +234,15 @@ module.exports = function(RED) {
|
|||||||
else { node.log('duplicate not sent: '+pay.topic); }
|
else { node.log('duplicate not sent: '+pay.topic); }
|
||||||
//node.status({fill:"green",shape:"dot",text:"ok"});
|
//node.status({fill:"green",shape:"dot",text:"ok"});
|
||||||
node.status({});
|
node.status({});
|
||||||
imap.end();
|
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
else {
|
else {
|
||||||
node.log("you have achieved inbox zero");
|
node.log("you have achieved inbox zero");
|
||||||
//node.status({fill:"green",shape:"dot",text:"ok"});
|
//node.status({fill:"green",shape:"dot",text:"ok"});
|
||||||
node.status({});
|
node.status({});
|
||||||
imap.end();
|
|
||||||
}
|
}
|
||||||
|
}
|
||||||
|
imap.end();
|
||||||
});
|
});
|
||||||
});
|
});
|
||||||
node.status({fill:"grey",shape:"dot",text:"connecting"});
|
node.status({fill:"grey",shape:"dot",text:"connecting"});
|
||||||
|
Loading…
Reference in New Issue
Block a user