mirror of
				https://github.com/node-red/node-red.git
				synced 2025-03-01 10:36:34 +00:00 
			
		
		
		
	add Status to email, http nodes (update copyright on tcp)
This commit is contained in:
		| @@ -1,5 +1,5 @@ | |||||||
| /** | /** | ||||||
|  * Copyright 2013 IBM Corp. |  * Copyright 2013,2014 IBM Corp. | ||||||
|  * |  * | ||||||
|  * Licensed under the Apache License, Version 2.0 (the "License"); |  * Licensed under the Apache License, Version 2.0 (the "License"); | ||||||
|  * you may not use this file except in compliance with the License. |  * you may not use this file except in compliance with the License. | ||||||
| @@ -140,6 +140,7 @@ module.exports = function(RED) { | |||||||
|         var node = this; |         var node = this; | ||||||
|         var credentials = RED.nodes.getCredentials(n.id); |         var credentials = RED.nodes.getCredentials(n.id); | ||||||
|         this.on("input",function(msg) { |         this.on("input",function(msg) { | ||||||
|  |             node.status({fill:"blue",shape:"dot",text:"requesting"}); | ||||||
|             var url; |             var url; | ||||||
|             if (msg.url) { |             if (msg.url) { | ||||||
|                 url = msg.url; |                 url = msg.url; | ||||||
| @@ -193,12 +194,14 @@ module.exports = function(RED) { | |||||||
|                 }); |                 }); | ||||||
|                 res.on('end',function() { |                 res.on('end',function() { | ||||||
|                     node.send(msg); |                     node.send(msg); | ||||||
|  |                     node.status({}); | ||||||
|                 }); |                 }); | ||||||
|             }); |             }); | ||||||
|             req.on('error',function(err) { |             req.on('error',function(err) { | ||||||
|                 msg.payload = err.toString(); |                 msg.payload = err.toString(); | ||||||
|                 msg.statusCode = err.code; |                 msg.statusCode = err.code; | ||||||
|                 node.send(msg); |                 node.send(msg); | ||||||
|  |                 node.status({fill:"red",shape:"ring",text:err.code}); | ||||||
|             }); |             }); | ||||||
|             if (payload) { |             if (payload) { | ||||||
|                 req.write(payload); |                 req.write(payload); | ||||||
|   | |||||||
| @@ -1,5 +1,5 @@ | |||||||
| /** | /** | ||||||
|  * Copyright 2013 IBM Corp. |  * Copyright 2013,2014 IBM Corp. | ||||||
|  * |  * | ||||||
|  * Licensed under the Apache License, Version 2.0 (the "License"); |  * Licensed under the Apache License, Version 2.0 (the "License"); | ||||||
|  * you may not use this file except in compliance with the License. |  * you may not use this file except in compliance with the License. | ||||||
|   | |||||||
| @@ -1,5 +1,5 @@ | |||||||
| <!-- | <!-- | ||||||
|   Copyright 2013 IBM Corp. |   Copyright 2013,2014 IBM Corp. | ||||||
|  |  | ||||||
|   Licensed under the Apache License, Version 2.0 (the "License"); |   Licensed under the Apache License, Version 2.0 (the "License"); | ||||||
|   you may not use this file except in compliance with the License. |   you may not use this file except in compliance with the License. | ||||||
|   | |||||||
| @@ -1,5 +1,5 @@ | |||||||
| /** | /** | ||||||
|  * Copyright 2013 IBM Corp. |  * Copyright 2013,2014 IBM Corp. | ||||||
|  * |  * | ||||||
|  * Licensed under the Apache License, Version 2.0 (the "License"); |  * Licensed under the Apache License, Version 2.0 (the "License"); | ||||||
|  * you may not use this file except in compliance with the License. |  * you may not use this file except in compliance with the License. | ||||||
| @@ -26,7 +26,6 @@ module.exports = function(RED) { | |||||||
|  |  | ||||||
|     //console.log(nodemailer.Transport.transports.SMTP.wellKnownHosts); |     //console.log(nodemailer.Transport.transports.SMTP.wellKnownHosts); | ||||||
|  |  | ||||||
|     // module.exports = { service: "Gmail", user: "blahblah@gmail.com", pass: "password", server: "imap.gmail.com", port: "993" } |  | ||||||
|     try { var globalkeys = RED.settings.email || require(process.env.NODE_RED_HOME+"/../emailkeys.js"); } |     try { var globalkeys = RED.settings.email || require(process.env.NODE_RED_HOME+"/../emailkeys.js"); } | ||||||
|     catch(err) { } |     catch(err) { } | ||||||
|  |  | ||||||
| @@ -68,8 +67,8 @@ module.exports = function(RED) { | |||||||
|         }); |         }); | ||||||
|  |  | ||||||
|         this.on("input", function(msg) { |         this.on("input", function(msg) { | ||||||
|             //node.log("email :",this.id,this.topic," received",msg.payload); |  | ||||||
|             if (msg != null) { |             if (msg != null) { | ||||||
|  |                 node.status({fill:"blue",shape:"dot",text:"sending"},true); | ||||||
|                 if (smtpTransport) { |                 if (smtpTransport) { | ||||||
|                     smtpTransport.sendMail({ |                     smtpTransport.sendMail({ | ||||||
|                         from: node.userid, // sender address |                         from: node.userid, // sender address | ||||||
| @@ -79,8 +78,10 @@ module.exports = function(RED) { | |||||||
|                     }, function(error, response) { |                     }, function(error, response) { | ||||||
|                         if (error) { |                         if (error) { | ||||||
|                             node.error(error); |                             node.error(error); | ||||||
|  |                             node.status({fill:"red",shape:"ring",text:"post error"},true); | ||||||
|                         } else { |                         } else { | ||||||
|                             node.log("Message sent: " + response.message); |                             node.log("Message sent: " + response.message); | ||||||
|  |                             node.status({},true); | ||||||
|                         } |                         } | ||||||
|                     }); |                     }); | ||||||
|                 } |                 } | ||||||
| @@ -133,6 +134,7 @@ module.exports = function(RED) { | |||||||
|  |  | ||||||
|         this.on("input", function(msg) { |         this.on("input", function(msg) { | ||||||
|             imap.once('ready', function() { |             imap.once('ready', function() { | ||||||
|  |                 node.status({fill:"blue",shape:"dot",text:"fetching"},true); | ||||||
|                 var pay = {}; |                 var pay = {}; | ||||||
|                 imap.openBox('INBOX', true, function(err, box) { |                 imap.openBox('INBOX', true, function(err, box) { | ||||||
|                     if (box.messages.total > 0) { |                     if (box.messages.total > 0) { | ||||||
| @@ -170,6 +172,7 @@ module.exports = function(RED) { | |||||||
|                         }); |                         }); | ||||||
|                         f.on('error', function(err) { |                         f.on('error', function(err) { | ||||||
|                             node.warn('fetch error: ' + err); |                             node.warn('fetch error: ' + err); | ||||||
|  |                             node.status({fill:"red",shape:"ring",text:"fetch error"},true); | ||||||
|                         }); |                         }); | ||||||
|                         f.on('end', function() { |                         f.on('end', function() { | ||||||
|                             if (JSON.stringify(pay) !== oldmail) { |                             if (JSON.stringify(pay) !== oldmail) { | ||||||
| @@ -178,19 +181,26 @@ module.exports = function(RED) { | |||||||
|                                 node.log('received new email: '+pay.topic); |                                 node.log('received new email: '+pay.topic); | ||||||
|                             } |                             } | ||||||
|                             else { node.log('duplicate not sent: '+pay.topic); } |                             else { node.log('duplicate not sent: '+pay.topic); } | ||||||
|  |                             //node.status({fill:"green",shape:"dot",text:"ok"},true); | ||||||
|  |                             node.status({},true); | ||||||
|                             imap.end(); |                             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"},true); | ||||||
|  |                         node.status({},true); | ||||||
|                         imap.end(); |                         imap.end(); | ||||||
|                     } |                     } | ||||||
|                 }); |                 }); | ||||||
|             }); |             }); | ||||||
|  |             node.status({fill:"grey",shape:"dot",text:"connecting"},true); | ||||||
|  |             imap.connect(); | ||||||
|  |         }); | ||||||
|  |  | ||||||
|         imap.on('error', function(err) { |         imap.on('error', function(err) { | ||||||
|             node.log(err); |             node.log(err); | ||||||
|             }); |             node.status({fill:"red",shape:"ring",text:"connect error"},true); | ||||||
|             imap.connect(); |  | ||||||
|         }); |         }); | ||||||
|  |  | ||||||
|         this.on("error", function(err) { |         this.on("error", function(err) { | ||||||
|   | |||||||
		Reference in New Issue
	
	Block a user