From 45e4c6d9d44b4e62b4be6b3e04728ebe306579f2 Mon Sep 17 00:00:00 2001 From: Schreck1985 <41887216+Schreck1985@users.noreply.github.com> Date: Wed, 22 Aug 2018 14:57:42 +0200 Subject: [PATCH 01/24] Node red mail usetls (#480) * Default value for tls, checking if tls is set to false --- social/email/61-email.html | 6 ++++++ social/email/61-email.js | 7 ++++++- social/email/locales/en-US/61-email.json | 1 + 3 files changed, 13 insertions(+), 1 deletion(-) diff --git a/social/email/61-email.html b/social/email/61-email.html index 0d684a43..52e4c38d 100644 --- a/social/email/61-email.html +++ b/social/email/61-email.html @@ -49,6 +49,10 @@
+
+ + +
@@ -69,6 +73,7 @@

Alternatively you may provide msg.attachments which should contain an array of one or more attachments in nodemailer format.

If required by your recipient you may also pass in a msg.envelope object, typically containing extra from and to properties.

+

If you have own signed certificates, Nodemailer can complain about that and refuse sending the message. In this case you can try switching off TLS.

Note: uses SMTP with SSL to port 465.

@@ -81,6 +86,7 @@ server: {value:"smtp.gmail.com",required:true}, port: {value:"465",required:true}, secure: {value: true}, + tls: {value: true}, name: {value:""}, dname: {value:""} }, diff --git a/social/email/61-email.js b/social/email/61-email.js index 92a7cdea..e3e6a0fa 100644 --- a/social/email/61-email.js +++ b/social/email/61-email.js @@ -30,6 +30,7 @@ module.exports = function(RED) { this.outserver = n.server; this.outport = n.port; this.secure = n.secure; + this.tls = true; var flag = false; if (this.credentials && this.credentials.hasOwnProperty("userid")) { this.userid = this.credentials.userid; @@ -50,12 +51,16 @@ module.exports = function(RED) { if (flag) { RED.nodes.addCredentials(n.id,{userid:this.userid, password:this.password, global:true}); } + if (n.tls === false){ + this.tls = false; + } var node = this; var smtpOptions = { host: node.outserver, port: node.outport, - secure: node.secure + secure: node.secure, + tls: {rejectUnauthorized: node.tls} } if (this.userid && this.password) { diff --git a/social/email/locales/en-US/61-email.json b/social/email/locales/en-US/61-email.json index fbe47766..d3f05375 100644 --- a/social/email/locales/en-US/61-email.json +++ b/social/email/locales/en-US/61-email.json @@ -13,6 +13,7 @@ "folder": "Folder", "protocol": "Protocol", "useSSL": "Use SSL?", + "useTLS": "Use TLS?", "disposition": "Disposition", "none": "None", "read": "Mark Read", From 1b0f573f4e1f9e71b91c402e2c4061478a81315f Mon Sep 17 00:00:00 2001 From: Dave Conway-Jones Date: Wed, 22 Aug 2018 13:58:55 +0100 Subject: [PATCH 02/24] let sqlite add extensions --- storage/sqlite/README.md | 2 ++ storage/sqlite/package.json | 2 +- storage/sqlite/sqlite.html | 2 ++ storage/sqlite/sqlite.js | 39 ++++++++++++++++++++++++------------- 4 files changed, 30 insertions(+), 15 deletions(-) diff --git a/storage/sqlite/README.md b/storage/sqlite/README.md index 9d2b8d3c..ae94aee3 100644 --- a/storage/sqlite/README.md +++ b/storage/sqlite/README.md @@ -25,6 +25,8 @@ By it's very nature it is SQL injection... so *be careful* out there... Typically the returned payload will be an array of the result rows, (or an error). +You can load sqlite extensions by inputting a msg.extension property containing the full path and filename. + The reconnect timeout in milliseconds can be changed by adding a line to **settings.js** sqliteReconnectTime: 20000, diff --git a/storage/sqlite/package.json b/storage/sqlite/package.json index 7bf56945..c671502c 100644 --- a/storage/sqlite/package.json +++ b/storage/sqlite/package.json @@ -1,6 +1,6 @@ { "name": "node-red-node-sqlite", - "version": "0.3.2", + "version": "0.3.3", "description": "A sqlite node for Node-RED", "dependencies": { "sqlite3": "^4.0.2" diff --git a/storage/sqlite/sqlite.html b/storage/sqlite/sqlite.html index 923f817c..28d5d966 100644 --- a/storage/sqlite/sqlite.html +++ b/storage/sqlite/sqlite.html @@ -77,6 +77,8 @@ be sure to include $ on the parameter object key.

Using any SQL Query, the result is returned in msg.payload

Typically the returned payload will be an array of the result rows, (or an error).

+

You can load sqlite extensions by inputting a msg.extension property containing the full + path and filename.

The reconnect timeout in milliseconds can be changed by adding a line to settings.js

sqliteReconnectTime: 20000,

diff --git a/storage/sqlite/sqlite.js b/storage/sqlite/sqlite.js index c5ec8e0b..39c0bc68 100644 --- a/storage/sqlite/sqlite.js +++ b/storage/sqlite/sqlite.js @@ -43,12 +43,13 @@ module.exports = function(RED) { var node = this; node.status({}); - if (this.mydbConfig) { - this.mydbConfig.doConnect(); + if (node.mydbConfig) { + node.mydbConfig.doConnect(); node.status({fill:"green",shape:"dot",text:this.mydbConfig.mod}); var bind = []; - node.on("input", function(msg) { - if (this.sqlquery == "msg.topic"){ + + var doQuery = function(msg) { + if (node.sqlquery == "msg.topic"){ if (typeof msg.topic === 'string') { bind = Array.isArray(msg.payload) ? msg.payload : []; node.mydbConfig.db.all(msg.topic, bind, function(err, row) { @@ -64,7 +65,7 @@ module.exports = function(RED) { node.status({fill:"red",shape:"dot",text:"msg.topic error"}); } } - if (this.sqlquery == "batch") { + if (node.sqlquery == "batch") { if (typeof msg.topic === 'string') { node.mydbConfig.db.exec(msg.topic, function(err) { if (err) { node.error(err,msg);} @@ -79,10 +80,10 @@ module.exports = function(RED) { node.status({fill:"red", shape:"dot",text:"msg.topic error"}); } } - if (this.sqlquery == "fixed"){ - if (typeof this.sql === 'string'){ + if (node.sqlquery == "fixed"){ + if (typeof node.sql === 'string'){ bind = Array.isArray(msg.payload) ? msg.payload : []; - node.mydbConfig.db.all(this.sql, bind, function(err, row) { + node.mydbConfig.db.all(node.sql, bind, function(err, row) { if (err) { node.error(err,msg); } else { msg.payload = row; @@ -91,15 +92,15 @@ module.exports = function(RED) { }); } else{ - if (this.sql === null || this.sql == ""){ + if (node.sql === null || node.sql == ""){ node.error("SQL statement config not set up",msg); node.status({fill:"red",shape:"dot",text:"SQL config not set up"}); } } } - if (this.sqlquery == "prepared"){ - if (typeof this.sql === 'string' && typeof msg.params !== "undefined" && typeof msg.params === "object"){ - node.mydbConfig.db.all(this.sql, msg.params, function(err, row) { + if (node.sqlquery == "prepared"){ + if (typeof node.sql === 'string' && typeof msg.params !== "undefined" && typeof msg.params === "object"){ + node.mydbConfig.db.all(node.sql, msg.params, function(err, row) { if (err) { node.error(err,msg); } else { msg.payload = row; @@ -108,7 +109,7 @@ module.exports = function(RED) { }); } else{ - if (this.sql === null || this.sql == ""){ + if (node.sql === null || node.sql == ""){ node.error("Prepared statement config not set up",msg); node.status({fill:"red",shape:"dot",text:"Prepared statement not set up"}); } @@ -122,10 +123,20 @@ module.exports = function(RED) { } } } + } + + node.on("input", function(msg) { + if (msg.hasOwnProperty("extension")) { + node.mydbConfig.db.loadExtension(msg.extension, function(err) { + if (err) { node.error(err,msg); } + else { doQuery(msg); } + }); + } + else { doQuery(msg); } }); } else { - this.error("Sqlite database not configured"); + node.error("Sqlite database not configured"); } } RED.nodes.registerType("sqlite",SqliteNodeIn); From 0b65cd86528993d7bcce7c20007241016744c189 Mon Sep 17 00:00:00 2001 From: Dave Conway-Jones Date: Wed, 22 Aug 2018 23:47:03 +0100 Subject: [PATCH 03/24] sqlite - better handle extensions timing --- storage/sqlite/package.json | 2 +- storage/sqlite/sqlite.js | 82 ++++++++++++++++++++----------------- 2 files changed, 46 insertions(+), 38 deletions(-) diff --git a/storage/sqlite/package.json b/storage/sqlite/package.json index c671502c..cc31580a 100644 --- a/storage/sqlite/package.json +++ b/storage/sqlite/package.json @@ -1,6 +1,6 @@ { "name": "node-red-node-sqlite", - "version": "0.3.3", + "version": "0.3.4", "description": "A sqlite node for Node-RED", "dependencies": { "sqlite3": "^4.0.2" diff --git a/storage/sqlite/sqlite.js b/storage/sqlite/sqlite.js index 39c0bc68..540e21e4 100644 --- a/storage/sqlite/sqlite.js +++ b/storage/sqlite/sqlite.js @@ -51,14 +51,16 @@ module.exports = function(RED) { var doQuery = function(msg) { if (node.sqlquery == "msg.topic"){ if (typeof msg.topic === 'string') { - bind = Array.isArray(msg.payload) ? msg.payload : []; - node.mydbConfig.db.all(msg.topic, bind, function(err, row) { - if (err) { node.error(err,msg); } - else { - msg.payload = row; - node.send(msg); - } - }); + if (msg.topic.length > 0) { + bind = Array.isArray(msg.payload) ? msg.payload : []; + node.mydbConfig.db.all(msg.topic, bind, function(err, row) { + if (err) { node.error(err,msg); } + else { + msg.payload = row; + node.send(msg); + } + }); + } } else { node.error("msg.topic : the query is not defined as a string",msg); @@ -67,13 +69,15 @@ module.exports = function(RED) { } if (node.sqlquery == "batch") { if (typeof msg.topic === 'string') { - node.mydbConfig.db.exec(msg.topic, function(err) { - if (err) { node.error(err,msg);} - else { - msg.payload = []; - node.send(msg); - } - }); + if (msg.topic.length > 0) { + node.mydbConfig.db.exec(msg.topic, function(err) { + if (err) { node.error(err,msg);} + else { + msg.payload = []; + node.send(msg); + } + }); + } } else { node.error("msg.topic : the query is not defined as string", msg); @@ -81,43 +85,47 @@ module.exports = function(RED) { } } if (node.sqlquery == "fixed"){ - if (typeof node.sql === 'string'){ - bind = Array.isArray(msg.payload) ? msg.payload : []; - node.mydbConfig.db.all(node.sql, bind, function(err, row) { - if (err) { node.error(err,msg); } - else { - msg.payload = row; - node.send(msg); - } - }); + if (typeof node.sql === 'string') { + if (msg.payload && msg.payload.length > 0) { + bind = Array.isArray(msg.payload) ? msg.payload : []; + node.mydbConfig.db.all(node.sql, bind, function(err, row) { + if (err) { node.error(err,msg); } + else { + msg.payload = row; + node.send(msg); + } + }); + } } else{ - if (node.sql === null || node.sql == ""){ + if (node.sql === null || node.sql == "") { node.error("SQL statement config not set up",msg); node.status({fill:"red",shape:"dot",text:"SQL config not set up"}); } } } if (node.sqlquery == "prepared"){ - if (typeof node.sql === 'string' && typeof msg.params !== "undefined" && typeof msg.params === "object"){ - node.mydbConfig.db.all(node.sql, msg.params, function(err, row) { - if (err) { node.error(err,msg); } - else { - msg.payload = row; - node.send(msg); - } - }); + if (typeof node.sql === 'string' && typeof msg.params !== "undefined" && typeof msg.params === "object") { + if (node.sql.length > 0) { + node.mydbConfig.db.all(node.sql, msg.params, function(err, row) { + if (err) { node.error(err,msg); } + else { + msg.payload = row; + node.send(msg); + } + }); + } } - else{ - if (node.sql === null || node.sql == ""){ + else { + if (node.sql === null || node.sql == "") { node.error("Prepared statement config not set up",msg); node.status({fill:"red",shape:"dot",text:"Prepared statement not set up"}); } - if (typeof msg.params == "undefined"){ + if (typeof msg.params == "undefined") { node.error("msg.params not passed"); node.status({fill:"red",shape:"dot",text:"msg.params not defined"}); } - else if (typeof msg.params != "object"){ + else if (typeof msg.params != "object") { node.error("msg.params not an object"); node.status({fill:"red",shape:"dot",text:"msg.params not an object"}); } From 6d36f5db8a20fee08870254bbc5d0b0f29d48ef1 Mon Sep 17 00:00:00 2001 From: Dave Conway-Jones Date: Thu, 23 Aug 2018 08:55:51 +0100 Subject: [PATCH 04/24] sqlite - add test extension - half.c --- storage/sqlite/ext/half.c | 30 ++++++++++++++++++++++++++++++ storage/sqlite/ext/half.dylib | Bin 0 -> 4616 bytes 2 files changed, 30 insertions(+) create mode 100644 storage/sqlite/ext/half.c create mode 100755 storage/sqlite/ext/half.dylib diff --git a/storage/sqlite/ext/half.c b/storage/sqlite/ext/half.c new file mode 100644 index 00000000..5c746314 --- /dev/null +++ b/storage/sqlite/ext/half.c @@ -0,0 +1,30 @@ +/* Add your header comment here */ + +#include +SQLITE_EXTENSION_INIT1 + +/* +** The half() SQL function returns half of its input value. +*/ +static void halfFunc( + sqlite3_context *context, + int argc, + sqlite3_value **argv +){ + sqlite3_result_double(context, 0.5*sqlite3_value_double(argv[0])); +} + +/* SQLite invokes this routine once when it loads the extension. +** Create new functions, collating sequences, and virtual table +** modules here. This is usually the only exported symbol in +** the shared library. +*/ +int sqlite3_extension_init( + sqlite3 *db, + char **pzErrMsg, + const sqlite3_api_routines *pApi +){ + SQLITE_EXTENSION_INIT2(pApi) + sqlite3_create_function(db, "half", 1, SQLITE_ANY, 0, halfFunc, 0, 0); + return 0; +} diff --git a/storage/sqlite/ext/half.dylib b/storage/sqlite/ext/half.dylib new file mode 100755 index 0000000000000000000000000000000000000000..50bf666d04b3878bf6bb9755ca67e970bf774dc0 GIT binary patch literal 4616 zcmeHLO=uHA6rR}D|C%Zk6cvL6|G;c&E4CMHrI8VT5Ntsa8QLbPE6t|uCRz`LLKR%1 zP{e}=&+4(@rQQ_9suz0@@!%n#f(HdHBI3dNeVdtf4Jw{xAG~?<&HJ18W)FFJ{{7>R zB|=1Mgb<6t_24OhOQHcgA=ZH}M}$zSD|MpFKl*j4m@S-XjF_ShT&p!o6*41*1+(gS zldCGauiAvz`1(h+Voa-ip;TYqaTfws$Ga1)STEI1#H{g8gm`XY*mnB0L3O-I9gj7U z46Yy{7MYEfN)?^+wv$%2lg;C-I^L9yC$&9sb&Oz0zQYYaPG?6~M?hoxZ)8BlE#HB4 z;|YCY-*UOUqap6~`*@~rvpQk@6QHxknp=3ZJZ)kX4N!C3t6 zwt?4HouBC$$R^Sk2JBuaK%0daOIEgjUy+Y?Ovjk5z^fr8miv$^z{kKOetKlu!t9rO z0sa%MhZXb0UR-H;Io&os;q8^nM-QEfn%R}h_H(8 zu!XA0$1k{rOfIoM*oQ5!W!xkdzSVY(S!YOL2f_}79SA!Rb|CCP*nzMEVF&(~4s=WJ zogDwrF0a;oMosrPLv&1WDoZszO?l4_U#+(Rq&NCadc{xD>wYgwV6SlvOl7HYg)gq1 z@db?@!=~&#>+~KR@n+<7Eq}2KIo%oeM<7{BmFH%fo_eX*-V-_gsQvWAEGQA(bdh#K z-zUk0UhzvMU*j!?C|w)DFM3%*l2YAu|71*JmXf6-xYIItl%@9^9VI81JwU}}G6NpquVFJus> zfU`9bapleEDVoqJfyK=E>|Q*8sgHwop}zf590oD{+jTuRwZFl}-)|0d#Pm0qFA@VA zqCU+<(_P3_z$PC180BZB=P9O*LT~QB6&P?nLQKr}kv*FSRSm@?n^tb2*sFT+=Rjsy zScTl6CHyJ3Pgv)AhOKOV01DSiDywazZK!Xk`RpENPk%0XcBpk%&due{w Date: Thu, 23 Aug 2018 08:57:15 +0100 Subject: [PATCH 05/24] Daemon - allow manual start rather than always auto to close #479 --- utility/daemon/daemon.html | 13 +++++++++++-- utility/daemon/daemon.js | 2 ++ utility/daemon/package.json | 2 +- 3 files changed, 14 insertions(+), 3 deletions(-) diff --git a/utility/daemon/daemon.html b/utility/daemon/daemon.html index 58bf99f6..bdd5f28d 100644 --- a/utility/daemon/daemon.html +++ b/utility/daemon/daemon.html @@ -11,12 +11,17 @@
- + + +
+
+ +
- +
@@ -62,6 +67,7 @@ name: {value:""}, command: {value:"",required:true}, args: {value:""}, + autorun: {value:true}, cr: {value:false}, redo: {value:true}, op: {value:"string"}, @@ -77,6 +83,9 @@ }, labelStyle: function() { return this.name?"node_label_italic":""; + }, + oneditprepare: function() { + if (this.autorun === undefined) { $("#node-input-autorun").prop('checked', true); } } }); diff --git a/utility/daemon/daemon.js b/utility/daemon/daemon.js index 07e49709..97568c7d 100644 --- a/utility/daemon/daemon.js +++ b/utility/daemon/daemon.js @@ -12,6 +12,8 @@ module.exports = function(RED) { this.redo = n.redo; this.running = false; this.closer = n.closer || "SIGKILL"; + this.autorun = true; + if (n.autorun === false) { this.autorun = false; } var node = this; function inputlistener(msg) { diff --git a/utility/daemon/package.json b/utility/daemon/package.json index faeb72bd..a45c56c0 100644 --- a/utility/daemon/package.json +++ b/utility/daemon/package.json @@ -1,6 +1,6 @@ { "name" : "node-red-node-daemon", - "version" : "0.0.21", + "version" : "0.0.22", "description" : "A Node-RED node that runs and monitors a long running system command.", "dependencies" : { }, From a94157efe60f83d938d75e6e8a19bb909d03c11c Mon Sep 17 00:00:00 2001 From: Dave Conway-Jones Date: Fri, 24 Aug 2018 15:23:37 +0100 Subject: [PATCH 06/24] sqlite - fix fixed statement check --- storage/sqlite/package.json | 2 +- storage/sqlite/sqlite.js | 3 +-- 2 files changed, 2 insertions(+), 3 deletions(-) diff --git a/storage/sqlite/package.json b/storage/sqlite/package.json index cc31580a..9dd66ecb 100644 --- a/storage/sqlite/package.json +++ b/storage/sqlite/package.json @@ -1,6 +1,6 @@ { "name": "node-red-node-sqlite", - "version": "0.3.4", + "version": "0.3.5", "description": "A sqlite node for Node-RED", "dependencies": { "sqlite3": "^4.0.2" diff --git a/storage/sqlite/sqlite.js b/storage/sqlite/sqlite.js index 540e21e4..27a92cad 100644 --- a/storage/sqlite/sqlite.js +++ b/storage/sqlite/sqlite.js @@ -86,8 +86,7 @@ module.exports = function(RED) { } if (node.sqlquery == "fixed"){ if (typeof node.sql === 'string') { - if (msg.payload && msg.payload.length > 0) { - bind = Array.isArray(msg.payload) ? msg.payload : []; + if (node.sql.length > 0) { node.mydbConfig.db.all(node.sql, bind, function(err, row) { if (err) { node.error(err,msg); } else { From 52df7cb30f96ce6392ff9e2b11d78c93d19aff5c Mon Sep 17 00:00:00 2001 From: Dave Conway-Jones Date: Thu, 30 Aug 2018 13:05:39 +0100 Subject: [PATCH 07/24] Fix email msg cloning to close #442 to close #461 --- social/email/61-email.js | 8 ++++---- social/email/package.json | 4 ++-- 2 files changed, 6 insertions(+), 6 deletions(-) diff --git a/social/email/61-email.js b/social/email/61-email.js index e3e6a0fa..7294af9e 100644 --- a/social/email/61-email.js +++ b/social/email/61-email.js @@ -190,7 +190,7 @@ module.exports = function(RED) { // will be used to populate the email. // DCJ NOTE: - heirachical multipart mime parsers seem to not exist - this one is barely functional. function processNewMessage(msg, mailMessage) { - msg = JSON.parse(JSON.stringify(msg)); // Clone the message + msg = RED.util.cloneMessage(msg); // Clone the message // Populate the msg fields from the content of the email message // that we have just parsed. msg.payload = mailMessage.text; @@ -198,9 +198,9 @@ module.exports = function(RED) { msg.date = mailMessage.date; msg.header = mailMessage.headers; if (mailMessage.html) { msg.html = mailMessage.html; } - if (mailMessage.to && mailMessage.from.to > 0) { msg.to = mailMessage.to; } - if (mailMessage.cc && mailMessage.from.cc > 0) { msg.cc = mailMessage.cc; } - if (mailMessage.bcc && mailMessage.from.bcc > 0) { msg.bcc = mailMessage.bcc; } + if (mailMessage.to && mailMessage.to.length > 0) { msg.to = mailMessage.to; } + if (mailMessage.cc && mailMessage.cc.length > 0) { msg.cc = mailMessage.cc; } + if (mailMessage.bcc && mailMessage.bcc.length > 0) { msg.bcc = mailMessage.bcc; } if (mailMessage.from && mailMessage.from.length > 0) { msg.from = mailMessage.from[0].address; } if (mailMessage.attachments) { msg.attachments = mailMessage.attachments; } else { msg.attachments = []; } diff --git a/social/email/package.json b/social/email/package.json index 985817e0..07a9289a 100644 --- a/social/email/package.json +++ b/social/email/package.json @@ -1,11 +1,11 @@ { "name": "node-red-node-email", - "version": "1.0.0", + "version": "1.0.1", "description": "Node-RED nodes to send and receive simple emails", "dependencies": { "imap": "^0.8.19", "mailparser": "^0.6.2", - "nodemailer": "^4.6.4", + "nodemailer": "^4.6.8", "poplib": "^0.1.7" }, "repository": { From 337588e7ab3271ea2af6148e5299dce3f53e9944 Mon Sep 17 00:00:00 2001 From: Tom Brusehaver <41647049+tbrusehaver@users.noreply.github.com> Date: Mon, 3 Sep 2018 13:56:36 -0500 Subject: [PATCH 08/24] Fix for Email In Node Crashed Node-RED (#471) When attachments aren't correct. --- social/email/61-email.js | 23 +++++++++++++++++------ 1 file changed, 17 insertions(+), 6 deletions(-) diff --git a/social/email/61-email.js b/social/email/61-email.js index 7294af9e..a50ae6d8 100644 --- a/social/email/61-email.js +++ b/social/email/61-email.js @@ -226,6 +226,7 @@ module.exports = function(RED) { function nextMessage() { if (currentMessage > maxMessage) { pop3Client.quit(); + setInputRepeatTimeout(); return; } pop3Client.retr(currentMessage); @@ -248,6 +249,7 @@ module.exports = function(RED) { }); pop3Client.on("error", function(err) { + setInputRepeatTimeout(); node.log("error: " + JSON.stringify(err)); }); @@ -263,6 +265,7 @@ module.exports = function(RED) { } else { node.log(util.format("login error: %s %j", status, rawData)); pop3Client.quit(); + setInputRepeatTimeout(); } }); @@ -284,6 +287,7 @@ module.exports = function(RED) { else { node.log(util.format("retr error: %s %j", status, rawData)); pop3Client.quit(); + setInputRepeatTimeout(); } }); @@ -323,6 +327,7 @@ module.exports = function(RED) { node.status({fill:"red", shape:"ring", text:"email.status.foldererror"}); node.error(RED._("email.errors.fetchfail", {folder:node.box}),err); imap.end(); + setInputRepeatTimeout(); return; } //console.log("> search - err=%j, results=%j", err, results); @@ -330,6 +335,7 @@ module.exports = function(RED) { //console.log(" [X] - Nothing to fetch"); node.status({}); imap.end(); + setInputRepeatTimeout(); return; } @@ -377,10 +383,12 @@ module.exports = function(RED) { } else { cleanup(); } + setInputRepeatTimeout(); }); fetch.once('error', function(err) { console.log('Fetch error: ' + err); + setInputRepeatTimeout(); }); }); // End of imap->search }); // End of imap->openInbox @@ -424,16 +432,19 @@ module.exports = function(RED) { this.on("close", function() { if (this.interval_id != null) { - clearInterval(this.interval_id); + clearTimeout(this.interval_id); } if (imap) { imap.destroy(); } }); - // Set the repetition timer as needed - if (!isNaN(this.repeat) && this.repeat > 0) { - this.interval_id = setInterval( function() { - node.emit("input",{}); - }, this.repeat ); + function setInputRepeatTimeout() + { + // Set the repetition timer as needed + if (!isNaN(node.repeat) && node.repeat > 0) { + node.interval_id = setTimeout( function() { + node.emit("input",{}); + }, node.repeat ); + } } node.emit("input",{}); From 649f9f2fbf3f4f6ebee2854cf4b68b7e41b7f1b3 Mon Sep 17 00:00:00 2001 From: Dave Conway-Jones Date: Mon, 3 Sep 2018 20:06:36 +0100 Subject: [PATCH 09/24] Bump email node for pr attachment errors fix --- social/email/README.md | 6 ++++-- social/email/package.json | 2 +- 2 files changed, 5 insertions(+), 3 deletions(-) diff --git a/social/email/README.md b/social/email/README.md index aaf84e6e..d1c4b474 100644 --- a/social/email/README.md +++ b/social/email/README.md @@ -9,7 +9,7 @@ Pre-requisite You will need valid email credentials for your email server. -**Note :** Version 1.x of this node requires Node.js v6 or newer. +**Note :** Version 1.x of this node requires **Node.js v6** or newer. Install @@ -18,10 +18,12 @@ Install Version 0.x of this node is usually installed by default by Node-RED. To install version 1.x you need to uninstall the existing version. - sudo npm uninstall -g node-red-node-email + cd /usr/lib/node_modules/node-red + sudo npm uninstall --unsafe-perm node-red-node-email Then run the following command in your Node-RED user directory - typically `~/.node-red` + cd ~/.node-red npm i node-red-node-email **Note :** this installs the new version locally rather than globally. This can then be managed by the palette manager. diff --git a/social/email/package.json b/social/email/package.json index 07a9289a..da414702 100644 --- a/social/email/package.json +++ b/social/email/package.json @@ -1,6 +1,6 @@ { "name": "node-red-node-email", - "version": "1.0.1", + "version": "1.0.2", "description": "Node-RED nodes to send and receive simple emails", "dependencies": { "imap": "^0.8.19", From a2b90976137cd5e4edb0278205af0a2e7983eff6 Mon Sep 17 00:00:00 2001 From: Dave Conway-Jones Date: Tue, 4 Sep 2018 18:51:20 +0100 Subject: [PATCH 10/24] Email node - report when on old node.js --- social/email/61-email.js | 4 ++++ social/email/README.md | 4 ++-- social/email/package.json | 4 ++-- 3 files changed, 8 insertions(+), 4 deletions(-) diff --git a/social/email/61-email.js b/social/email/61-email.js index a50ae6d8..c33d3b6e 100644 --- a/social/email/61-email.js +++ b/social/email/61-email.js @@ -17,6 +17,10 @@ module.exports = function(RED) { var MailParser = require("mailparser").MailParser; var util = require("util"); + if (parseInt(process.version.split("v")[1].split(".")[0]) < 8) { + throw "Error : Requires nodejs version >= 8."; + } + try { var globalkeys = RED.settings.email || require(process.env.NODE_RED_HOME+"/../emailkeys.js"); } diff --git a/social/email/README.md b/social/email/README.md index d1c4b474..0cffc6e2 100644 --- a/social/email/README.md +++ b/social/email/README.md @@ -1,7 +1,7 @@ node-red-node-email =================== -Node-RED nodes to send and receive simple emails. +Node-RED nodes to send and receive simple emails. Pre-requisite @@ -9,7 +9,7 @@ Pre-requisite You will need valid email credentials for your email server. -**Note :** Version 1.x of this node requires **Node.js v6** or newer. +**Note :** Version 1.x of this node requires **Node.js v8** or newer. Install diff --git a/social/email/package.json b/social/email/package.json index da414702..02e447aa 100644 --- a/social/email/package.json +++ b/social/email/package.json @@ -1,6 +1,6 @@ { "name": "node-red-node-email", - "version": "1.0.2", + "version": "1.0.3", "description": "Node-RED nodes to send and receive simple emails", "dependencies": { "imap": "^0.8.19", @@ -30,6 +30,6 @@ "url": "http://nodered.org" }, "engines": { - "node": ">=6.0.0" + "node": ">=8.0.0" } } From 949bbe95cde586049f0b4616912bf1e2d4cd4bb1 Mon Sep 17 00:00:00 2001 From: Dave Conway-Jones Date: Thu, 6 Sep 2018 21:33:14 +0100 Subject: [PATCH 11/24] couple of file permissions and rm node6 --- .travis.yml | 1 - hardware/neopixel/neopixel.html | 0 hardware/neopixel/package.json | 0 3 files changed, 1 deletion(-) mode change 100755 => 100644 hardware/neopixel/neopixel.html mode change 100755 => 100644 hardware/neopixel/package.json diff --git a/.travis.yml b/.travis.yml index 7c414c5f..9bfec6ee 100644 --- a/.travis.yml +++ b/.travis.yml @@ -4,7 +4,6 @@ matrix: include: - node_js: 8 - node_js: 10 - - node_js: 6 - python: 2.7 language: python before_script: pip install flake8 diff --git a/hardware/neopixel/neopixel.html b/hardware/neopixel/neopixel.html old mode 100755 new mode 100644 diff --git a/hardware/neopixel/package.json b/hardware/neopixel/package.json old mode 100755 new mode 100644 From 8acc5064d0503441c0b45330af1da1d319a50ff6 Mon Sep 17 00:00:00 2001 From: Dave Conway-Jones Date: Mon, 10 Sep 2018 11:37:20 -0400 Subject: [PATCH 12/24] update notify package to use a more cross platform library --- social/notify/57-notify.html | 15 ++++++++------- social/notify/57-notify.js | 25 +++++++++++++++++-------- social/notify/node-red.png | Bin 0 -> 1019 bytes social/notify/package.json | 8 ++++---- 4 files changed, 29 insertions(+), 19 deletions(-) create mode 100644 social/notify/node-red.png diff --git a/social/notify/57-notify.html b/social/notify/57-notify.html index d0fc85d4..fe3244a2 100644 --- a/social/notify/57-notify.html +++ b/social/notify/57-notify.html @@ -1,5 +1,5 @@ - - diff --git a/social/pushover/README.md b/social/pushover/README.md index 86c592f9..158ccae7 100644 --- a/social/pushover/README.md +++ b/social/pushover/README.md @@ -16,12 +16,14 @@ Usage Uses Pushover to push the `msg.payload` to a device that has the Pushover app installed. -Optionally uses `msg.topic` to set the title, `msg.device` to set the device -and `msg.priority` to set the priority, if not already set in the properties. -Optionally uses `msg.topic` to set the title, `msg.device` to set the device, -`msg.priority` to set the priority, `msg.url` to add a web address and `msg.url_title` -to add a url title - if not already set in the properties. +Optionally uses `msg.topic` to set the configuration, if not already set in the properties: + - `msg.device`: to set the device + - `msg.priority`: to set the priority + - `msg.topic`: to set the title + - `msg.url`: to add a web address + - `msg.url_title`: to add a url title + - `msg.sound`: to set the alert sound, see the [available options](https://pushover.net/api#sounds) The User-key and API-token are stored in a separate credentials file. From eae67c7a6c37f8887e57b2c7c0ffd598fb0788ec Mon Sep 17 00:00:00 2001 From: Dave Conway-Jones Date: Mon, 17 Sep 2018 20:00:45 +0100 Subject: [PATCH 19/24] bump pushover packe for docs pr --- social/pushover/package.json | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/social/pushover/package.json b/social/pushover/package.json index 2a52ec45..ccc56b22 100644 --- a/social/pushover/package.json +++ b/social/pushover/package.json @@ -1,6 +1,6 @@ { "name" : "node-red-node-pushover", - "version" : "0.0.12", + "version" : "0.0.13", "description" : "A Node-RED node to send alerts via Pushover", "dependencies" : { "pushover-notifications" : "~0.2.4" From 23ba609653ea4c080aa41f7acda154dcf78db65b Mon Sep 17 00:00:00 2001 From: Dave Conway-Jones Date: Fri, 21 Sep 2018 13:53:08 +0100 Subject: [PATCH 20/24] Add SPIdev choice to mcpxxxx node --- hardware/mcp3008/README.md | 2 ++ hardware/mcp3008/package.json | 4 ++-- hardware/mcp3008/pimcp3008.html | 10 +++++++++- hardware/mcp3008/pimcp3008.js | 5 +++-- 4 files changed, 16 insertions(+), 5 deletions(-) diff --git a/hardware/mcp3008/README.md b/hardware/mcp3008/README.md index 0914d49c..5ab83009 100644 --- a/hardware/mcp3008/README.md +++ b/hardware/mcp3008/README.md @@ -37,6 +37,8 @@ select the channel dynamically. If so then the payload must be a value from 0 to You can also select device id 0 or 1 (CE0 or CE1) depending on how you have wired up your device. Defaults to CE0. +And you can also select the SPI bus number 0 or 1 depending on how you have wired up your device. Defaults to 0 for spidev0. + Outputs a numeric `msg.payload` with a range of 0 to 1023, where 0 = 0V and 1023 = 3.3V (assuming you use the default 3.3V voltage reference). **Hint**: use a `range` node to adjust the values to the range you want. diff --git a/hardware/mcp3008/package.json b/hardware/mcp3008/package.json index bf89c672..f9a6a028 100644 --- a/hardware/mcp3008/package.json +++ b/hardware/mcp3008/package.json @@ -1,9 +1,9 @@ { "name" : "node-red-node-pi-mcp3008", - "version" : "0.1.1", + "version" : "0.2.0", "description" : "A Node-RED node to read from the MCP3008 Analogue to Digital Converter", "dependencies" : { - "mcp-spi-adc": "^1.0.0" + "mcp-spi-adc": "^2.0.3" }, "repository" : { "type":"git", diff --git a/hardware/mcp3008/pimcp3008.html b/hardware/mcp3008/pimcp3008.html index 59c2dbcc..3fafb671 100644 --- a/hardware/mcp3008/pimcp3008.html +++ b/hardware/mcp3008/pimcp3008.html @@ -33,6 +33,13 @@
+
+ + +
@@ -61,7 +68,8 @@ name: {value:""}, dev: {value:"3008"}, pin: {value:0, required:true}, - dnum: {value:0} + dnum: {value:0}, + bus: {value:0} }, inputs: 1, outputs: 1, diff --git a/hardware/mcp3008/pimcp3008.js b/hardware/mcp3008/pimcp3008.js index ee5e835f..492f8d6b 100644 --- a/hardware/mcp3008/pimcp3008.js +++ b/hardware/mcp3008/pimcp3008.js @@ -19,14 +19,15 @@ module.exports = function(RED) { this.pin = n.pin || 0; this.interval = n.interval || 1000; this.dnum = parseInt(n.dnum || 0); + this.bus = parseInt(n.bus || 0); this.dev = n.dev || "3008"; var node = this; var cb = function (err) { if (err) { node.error("Error: "+err); } }; - var opt = { speedHz:20000, deviceNumber:node.dnum }; + var opt = { speedHz:20000, deviceNumber:node.dnum, busNumber:node.bus }; var chans = parseInt(this.dev.substr(3)); try { - fs.statSync("/dev/spidev0."+node.dnum); + fs.statSync("/dev/spidev"+node.bus+"."+node.dnum); if (mcp3xxx.length === 0) { for (var i=0; i Date: Sun, 23 Sep 2018 20:32:11 +0100 Subject: [PATCH 21/24] check for correct version of neopixel library --- hardware/neopixel/neopixel.js | 2 +- hardware/neopixel/package.json | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) mode change 100755 => 100644 hardware/neopixel/neopixel.js diff --git a/hardware/neopixel/neopixel.js b/hardware/neopixel/neopixel.js old mode 100755 new mode 100644 index c8781367..815326e3 --- a/hardware/neopixel/neopixel.js +++ b/hardware/neopixel/neopixel.js @@ -14,7 +14,7 @@ module.exports = function(RED) { RED.log.warn("rpi-neopixels : "+RED._("node-red:rpi-gpio.errors.ignorenode")); allOK = false; } - else if (execSync('python -c "import neopixel"').toString() !== "") { + else if (execSync('python -c "import rpi_ws281x"').toString() !== "") { RED.log.warn("rpi-neopixels : Can't find neopixel python library"); allOK = false; } diff --git a/hardware/neopixel/package.json b/hardware/neopixel/package.json index eca2cf6b..a9bf250a 100644 --- a/hardware/neopixel/package.json +++ b/hardware/neopixel/package.json @@ -1,6 +1,6 @@ { "name" : "node-red-node-pi-neopixel", - "version" : "0.0.21", + "version" : "0.0.22", "description" : "A Node-RED node to output to a neopixel (ws2812) string of LEDS from a Raspberry Pi.", "dependencies" : { }, From d32f11910bc28a77557755c9f9544f3dedd7dd39 Mon Sep 17 00:00:00 2001 From: Dave Conway-Jones Date: Mon, 24 Sep 2018 19:40:33 +0100 Subject: [PATCH 22/24] clarify random node info language --- function/random/package.json | 2 +- function/random/random.html | 6 ++++-- function/random/random.js | 4 ++-- 3 files changed, 7 insertions(+), 5 deletions(-) diff --git a/function/random/package.json b/function/random/package.json index 4898c021..ee980c8d 100644 --- a/function/random/package.json +++ b/function/random/package.json @@ -1,6 +1,6 @@ { "name" : "node-red-node-random", - "version" : "0.1.0", + "version" : "0.1.1", "description" : "A Node-RED node that when triggered generates a random number between two values.", "dependencies" : { }, diff --git a/function/random/random.html b/function/random/random.html index 0f2c3824..3e103aef 100644 --- a/function/random/random.html +++ b/function/random/random.html @@ -28,8 +28,10 @@ 70%