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

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

This commit is contained in:
Nick O'Leary 2020-02-25 15:09:26 +00:00
commit c9ad5bea93
No known key found for this signature in database
GPG Key ID: 4F2157149161A6C9
4 changed files with 17 additions and 10 deletions

View File

@ -351,7 +351,8 @@
"bool": "bool", "bool": "bool",
"json": "JSON", "json": "JSON",
"bin": "buffer", "bin": "buffer",
"env": "env variable" "env": "env variable",
"cred": "credential"
}, },
"menu": { "menu": {
"input": "input", "input": "input",

View File

@ -351,7 +351,8 @@
"bool": "真偽", "bool": "真偽",
"json": "JSON", "json": "JSON",
"bin": "バッファ", "bin": "バッファ",
"env": "環境変数" "env": "環境変数",
"cred": "認証情報"
}, },
"menu": { "menu": {
"input": "入力", "input": "入力",

View File

@ -106,7 +106,9 @@ module.exports = function(RED) {
}); });
} }
var npay;
this.on('input', function(msg) { this.on('input', function(msg) {
if (node.op2type === "payl") { npay = RED.util.cloneMessage(msg); }
processMessageQueue(msg); processMessageQueue(msg);
}); });
@ -124,7 +126,7 @@ module.exports = function(RED) {
else { else {
if (((!node.topics[topic].tout) && (node.topics[topic].tout !== 0)) || (node.loop === true)) { if (((!node.topics[topic].tout) && (node.topics[topic].tout !== 0)) || (node.loop === true)) {
promise = Promise.resolve(); promise = Promise.resolve();
if (node.op2type === "pay" || node.op2type === "payl") { node.topics[topic].m2 = RED.util.cloneMessage(msg.payload); } if (node.op2type === "pay") { node.topics[topic].m2 = RED.util.cloneMessage(msg.payload); }
else if (node.op2Templated) { node.topics[topic].m2 = mustache.render(node.op2,msg); } else if (node.op2Templated) { node.topics[topic].m2 = mustache.render(node.op2,msg); }
else if (node.op2type !== "nul") { else if (node.op2type !== "nul") {
promise = new Promise((resolve,reject) => { promise = new Promise((resolve,reject) => {
@ -188,7 +190,8 @@ module.exports = function(RED) {
promise.then(() => { promise.then(() => {
msg2.payload = node.topics[topic].m2; msg2.payload = node.topics[topic].m2;
delete node.topics[topic]; delete node.topics[topic];
node.send(msg2); if (node.op2type === "payl") { node.send(npay); }
else { node.send(msg2); }
node.status({}); node.status({});
}).catch(err => { }).catch(err => {
node.error(err); node.error(err);
@ -244,9 +247,9 @@ module.exports = function(RED) {
}); });
}, node.duration); }, node.duration);
} }
else { // else {
if (node.op2type === "payl") { node.topics[topic].m2 = RED.util.cloneMessage(msg.payload); } // if (node.op2type === "payl") {node.topics[topic].m2 = RED.util.cloneMessage(msg.payload); }
} // }
} }
return Promise.resolve(); return Promise.resolve();
} }

View File

@ -736,10 +736,12 @@ describe('trigger node', function() {
try { try {
if (c === 0) { if (c === 0) {
msg.should.have.a.property("payload", "Goodbye"); msg.should.have.a.property("payload", "Goodbye");
msg.should.have.a.property("topic", "test2");
c += 1; c += 1;
} }
else { else {
msg.should.have.a.property("payload", "World"); msg.should.have.a.property("payload", "World");
msg.should.have.a.property("topic", "test3");
(Date.now() - ss).should.be.greaterThan(70); (Date.now() - ss).should.be.greaterThan(70);
done(); done();
} }
@ -747,12 +749,12 @@ describe('trigger node', function() {
catch(err) { done(err); } catch(err) { done(err); }
}); });
var ss = Date.now(); var ss = Date.now();
n1.emit("input", {payload:"Hello"}); n1.emit("input", {payload:"Hello", topic:"test1"});
setTimeout( function() { setTimeout( function() {
n1.emit("input", {payload:"Goodbye"}); n1.emit("input", {payload:"Goodbye", topic:"test2"});
},20); },20);
setTimeout( function() { setTimeout( function() {
n1.emit("input", {payload:"World"}); n1.emit("input", {payload:"World", topic:"test3"});
},80); },80);
}); });
}); });