1
0
mirror of https://github.com/node-red/node-red.git synced 2023-10-10 13:36:53 +02:00

Merge branch 'master' of github.com:node-red/node-red

This commit is contained in:
Nicholas O'Leary 2013-11-29 19:59:02 +00:00
commit a4a3322048

View File

@ -17,7 +17,6 @@
var RED = require(process.env.NODE_RED_HOME+"/red/red"); var RED = require(process.env.NODE_RED_HOME+"/red/red");
var Imap = require('imap'); var Imap = require('imap');
var util = require('util'); var util = require('util');
var oldmail = {};
try { try {
var emailkey = RED.settings.email || require(process.env.NODE_RED_HOME+"/../emailkeys.js"); var emailkey = RED.settings.email || require(process.env.NODE_RED_HOME+"/../emailkeys.js");
@ -45,6 +44,7 @@ function ImapNode(n) {
this.repeat = n.repeat * 1000 || 300000; this.repeat = n.repeat * 1000 || 300000;
var node = this; var node = this;
this.interval_id = null; this.interval_id = null;
var oldmail = {};
if (!isNaN(this.repeat) && this.repeat > 0) { if (!isNaN(this.repeat) && this.repeat > 0) {
node.log("repeat = "+this.repeat); node.log("repeat = "+this.repeat);
@ -97,9 +97,10 @@ function ImapNode(n) {
if (JSON.stringify(pay) !== oldmail) { if (JSON.stringify(pay) !== oldmail) {
node.send(pay); node.send(pay);
oldmail = JSON.stringify(pay); oldmail = JSON.stringify(pay);
node.log('sent new message: '+pay.topic);
} }
else { node.log('duplicate not sent: '+pay.topic); }
imap.end(); imap.end();
node.log('done fetching message');
}); });
}); });
}); });
@ -110,18 +111,15 @@ function ImapNode(n) {
util.log(err); util.log(err);
}); });
imap.on('end', function() { this.on("error", function(err) {
//util.log('Connection ended'); node.log("error: ",err);
}); });
this.on("close", function() { this.on("close", function() {
if (this.interval_id != null) { if (this.interval_id != null) {
clearInterval(this.interval_id); clearInterval(this.interval_id);
} }
}); imap.destroy();
this.on("error", function(err) {
node.log("error: ",err);
}); });
node.emit("input",{}); node.emit("input",{});