From 5f74a1d2376b278dce38ec0a15f5533a791c6174 Mon Sep 17 00:00:00 2001 From: Dave C-J Date: Mon, 1 Dec 2014 22:58:25 +0000 Subject: [PATCH] Update file, http and email nodes to only show deprecation warning if msg property is a real overide to node property ( !== ). Fix for comment by @drJeckyll to Issue #399 --- nodes/core/io/21-httpin.js | 9 +++++---- nodes/core/social/61-email.js | 2 +- nodes/core/storage/50-file.js | 4 ++-- 3 files changed, 8 insertions(+), 7 deletions(-) diff --git a/nodes/core/io/21-httpin.js b/nodes/core/io/21-httpin.js index cb6648421..ff67ead6f 100644 --- a/nodes/core/io/21-httpin.js +++ b/nodes/core/io/21-httpin.js @@ -68,7 +68,7 @@ module.exports = function(RED) { } }; - var corsHandler = function(req,res,next) { next(); }; + var corsHandler = function(req,res,next) { next(); } if (RED.settings.httpNodeCors) { corsHandler = cors(RED.settings.httpNodeCors); @@ -144,6 +144,7 @@ module.exports = function(RED) { } RED.nodes.registerType("http response",HTTPOut); + function HTTPRequest(n) { RED.nodes.createNode(this,n); var nodeUrl = n.url; @@ -154,7 +155,7 @@ module.exports = function(RED) { node.status({fill:"blue",shape:"dot",text:"requesting"}); var url; if (msg.url) { - if (n.url) { + if (n.url && (n.url !== msg.url)) { node.warn("Deprecated: msg properties should not override set node properties. See bit.ly/nr-override-msg-props"); } url = msg.url; @@ -170,7 +171,7 @@ module.exports = function(RED) { var method; if (msg.method) { - if (n.method) { + if (n.method && (n.method !== msg.method)) { node.warn("Deprecated: msg properties should not override set node properties. See bit.ly/nr-override-msg-props"); } method = msg.method.toUpperCase(); @@ -251,4 +252,4 @@ module.exports = function(RED) { password: {type: "password"} } }); -}; +} diff --git a/nodes/core/social/61-email.js b/nodes/core/social/61-email.js index 74d24d6ab..393d588de 100644 --- a/nodes/core/social/61-email.js +++ b/nodes/core/social/61-email.js @@ -72,7 +72,7 @@ module.exports = function(RED) { if (smtpTransport) { node.status({fill:"blue",shape:"dot",text:"sending"}); var payload = RED.util.ensureString(msg.payload); - if (msg.to && node.name) { + if (msg.to && node.name && (msg.to !== node.name)) { node.warn("Deprecated: msg properties should not override set node properties. See bit.ly/nr-override-msg-props"); } smtpTransport.sendMail({ diff --git a/nodes/core/storage/50-file.js b/nodes/core/storage/50-file.js index bec080645..a92c62b7b 100644 --- a/nodes/core/storage/50-file.js +++ b/nodes/core/storage/50-file.js @@ -27,7 +27,7 @@ module.exports = function(RED) { this.on("input",function(msg) { var filename; if (msg.filename) { - if (n.filename) { + if (n.filename && (n.filename !== msg.filename)) { node.warn("Deprecated: msg properties should not override set node properties. See bit.ly/nr-override-msg-props"); } filename = msg.filename; @@ -89,7 +89,7 @@ module.exports = function(RED) { this.on("input",function(msg) { var filename; if (msg.filename) { - if (n.filename) { + if (n.filename && (n.filename !== msg.filename)) { node.warn("Deprecated: msg properties should not override set node properties. See bit.ly/nr-override-msg-props"); } filename = msg.filename;