mirror of
https://github.com/node-red/node-red.git
synced 2023-10-10 13:36:53 +02:00
reverse overide behaviour on file, http and email. Node properties now
have priority. Warn user if msg.property tries to override. Warning should be removed at next major verion bump.
This commit is contained in:
parent
df065e94b7
commit
9afb4a9315
@ -177,34 +177,24 @@ module.exports = function(RED) {
|
||||
this.on("input",function(msg) {
|
||||
var preRequestTimestamp = process.hrtime();
|
||||
node.status({fill:"blue",shape:"dot",text:"requesting"});
|
||||
var url;
|
||||
if (msg.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");
|
||||
var url = nodeUrl || msg.url;
|
||||
if (msg.url && nodeUrl && (nodeUrl !== msg.url)) { // revert change below when warning is finally removed
|
||||
node.warn("Warning: msg properties can no longer override set node properties. See bit.ly/nr-override-msg-props");
|
||||
}
|
||||
url = msg.url;
|
||||
} else if (isTemplatedUrl) {
|
||||
if (isTemplatedUrl) {
|
||||
url = mustache.render(nodeUrl,msg);
|
||||
} else {
|
||||
url = nodeUrl;
|
||||
}
|
||||
// url must start http:// or https:// so assume http:// if not set
|
||||
if (!((url.indexOf("http://")===0) || (url.indexOf("https://")===0))) {
|
||||
url = "http://"+url;
|
||||
}
|
||||
|
||||
var method;
|
||||
if (msg.method) { // if method set in msg
|
||||
if (n.method && (n.method !== "use")) { // warn if override option not set
|
||||
node.warn("Deprecated: msg properties should not override fixed node properties. Use explicit override option. See bit.ly/nr-override-msg-props");
|
||||
}
|
||||
method = msg.method.toUpperCase(); // but use it anyway
|
||||
} else {
|
||||
if (n.method !== "use") {
|
||||
method = nodeMethod.toUpperCase(); // otherwise use the selected method
|
||||
} else { // unless they selected override
|
||||
method = "GET"; // - in which case default to GET
|
||||
var method = nodeMethod.toUpperCase() || "GET";
|
||||
if (msg.method && n.method && (n.method !== "use")) { // warn if override option not set
|
||||
node.warn("Warning: msg properties can no longer override fixed node properties. Use explicit override option. See bit.ly/nr-override-msg-props");
|
||||
}
|
||||
if (msg.method && n.method && (n.method === "use")) {
|
||||
method = msg.method.toUpperCase(); // use the msg parameter
|
||||
}
|
||||
var opts = urllib.parse(url);
|
||||
opts.method = method;
|
||||
@ -251,7 +241,7 @@ module.exports = function(RED) {
|
||||
msg.statusCode = res.statusCode;
|
||||
msg.headers = res.headers;
|
||||
msg.payload = "";
|
||||
// msg.url = url; // revert when fully deprecated
|
||||
// msg.url = url; // revert when warning above finally removed
|
||||
res.on('data',function(chunk) {
|
||||
msg.payload += chunk;
|
||||
});
|
||||
|
@ -87,7 +87,7 @@
|
||||
defaults: {
|
||||
server: {value:"smtp.gmail.com",required:true},
|
||||
port: {value:"465",required:true},
|
||||
name: {value:"",required:true},
|
||||
name: {value:""},
|
||||
dname: {value:""}
|
||||
},
|
||||
credentials: {
|
||||
@ -95,7 +95,6 @@
|
||||
password: {type: "password"},
|
||||
global: { type:"boolean"}
|
||||
},
|
||||
|
||||
inputs:1,
|
||||
outputs:0,
|
||||
icon: "envelope.png",
|
||||
|
@ -72,10 +72,10 @@ module.exports = function(RED) {
|
||||
if (smtpTransport) {
|
||||
node.status({fill:"blue",shape:"dot",text:"sending"});
|
||||
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");
|
||||
node.warn("Warning: msg properties can no longer override set node properties. See bit.ly/nr-override-msg-props");
|
||||
}
|
||||
var sendopts = { from: node.userid }; // sender address
|
||||
sendopts.to = msg.to || node.name; // comma separated list of addressees
|
||||
sendopts.to = node.name || msg.to; // comma separated list of addressees
|
||||
sendopts.subject = msg.topic || msg.title || "Message from Node-RED"; // subject line
|
||||
if (Buffer.isBuffer(msg.payload)) { // if it's a buffer in the payload then auto create an attachment instead
|
||||
sendopts.attachments = [ { content: msg.payload, filename:(msg.filename.replace(/^.*[\\\/]/, '') || "file.bin") } ];
|
||||
|
@ -85,7 +85,7 @@
|
||||
align: "right",
|
||||
label: function() {
|
||||
if (this.overwriteFile === "delete") { return this.name||"delete "+this.filename; }
|
||||
else { return this.name||this.filename; }
|
||||
else { return this.name||this.filename||"file"; }
|
||||
},
|
||||
labelStyle: function() {
|
||||
return this.name?"node_label_italic":"";
|
||||
@ -110,7 +110,7 @@
|
||||
outputs:1,
|
||||
icon: "file.png",
|
||||
label: function() {
|
||||
return this.name||this.filename;
|
||||
return this.name||this.filename||"file";
|
||||
},
|
||||
labelStyle: function() {
|
||||
return this.name?"node_label_italic":"";
|
||||
|
@ -20,29 +20,26 @@ module.exports = function(RED) {
|
||||
|
||||
function FileNode(n) {
|
||||
RED.nodes.createNode(this,n);
|
||||
this.filename = n.filename || "";
|
||||
this.filename = n.filename;
|
||||
this.appendNewline = n.appendNewline;
|
||||
this.overwriteFile = n.overwriteFile.toString();
|
||||
var node = this;
|
||||
this.on("input",function(msg) {
|
||||
var filename;
|
||||
if (msg.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");
|
||||
var filename = this.filename || msg.filename || "";
|
||||
if (msg.filename && n.filename && (n.filename !== msg.filename)) {
|
||||
node.warn("Warning: msg properties can no longer override set node properties. See bit.ly/nr-override-msg-props");
|
||||
}
|
||||
filename = msg.filename;
|
||||
node.status({fill:"grey",shape:"dot",text:msg.filename});
|
||||
} else {
|
||||
filename = this.filename;
|
||||
if (!this.filename) {
|
||||
node.status({fill:"grey",shape:"dot",text:filename});
|
||||
}
|
||||
if (filename === "") {
|
||||
node.warn('No filename specified');
|
||||
} else if (msg.hasOwnProperty('delete')) {
|
||||
node.warn("Deprecated: please use specific delete option in config dialog.");
|
||||
fs.unlink(filename, function (err) {
|
||||
if (err) { node.error('Failed to delete file : '+err,msg); }
|
||||
});
|
||||
} else if (typeof msg.payload != "undefined") {
|
||||
} else if (msg.hasOwnProperty('delete')) { // remove warning at some point in future
|
||||
node.warn("Warning: Invalid delete. Please use specific delete option in config dialog.");
|
||||
//fs.unlink(filename, function (err) {
|
||||
//if (err) { node.error('Failed to delete file : '+err,msg); }
|
||||
//});
|
||||
} else if (msg.payload && (typeof msg.payload != "undefined")) {
|
||||
var data = msg.payload;
|
||||
if ((typeof data === "object")&&(!Buffer.isBuffer(data))) {
|
||||
data = JSON.stringify(data);
|
||||
@ -80,7 +77,7 @@ module.exports = function(RED) {
|
||||
function FileInNode(n) {
|
||||
RED.nodes.createNode(this,n);
|
||||
|
||||
this.filename = n.filename || "";
|
||||
this.filename = n.filename;
|
||||
this.format = n.format;
|
||||
var node = this;
|
||||
var options = {};
|
||||
@ -88,14 +85,12 @@ module.exports = function(RED) {
|
||||
options['encoding'] = this.format;
|
||||
}
|
||||
this.on("input",function(msg) {
|
||||
var filename;
|
||||
if (msg.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");
|
||||
var filename = this.filename || msg.filename || "";
|
||||
if (msg.filename && n.filename && (n.filename !== msg.filename)) {
|
||||
node.warn("Warning: msg properties can no longer override set node properties. See bit.ly/nr-override-msg-props");
|
||||
}
|
||||
filename = msg.filename;
|
||||
} else {
|
||||
filename = this.filename;
|
||||
if (!this.filename) {
|
||||
node.status({fill:"grey",shape:"dot",text:filename});
|
||||
}
|
||||
if (filename === "") {
|
||||
node.warn('No filename specified');
|
||||
|
Loading…
Reference in New Issue
Block a user