mirror of
https://github.com/node-red/node-red.git
synced 2023-10-10 13:36:53 +02:00
automatically use resposeTopic if topic is empty
This commit is contained in:
parent
6917919f35
commit
27550f2d4b
@ -758,9 +758,14 @@ module.exports = function(RED) {
|
||||
}
|
||||
if ( msg.hasOwnProperty("payload")) {
|
||||
let topicOK = msg.hasOwnProperty("topic") && (typeof msg.topic === "string") && (msg.topic !== "");
|
||||
if(!topicOK && v5 && msg.topicAlias && node.brokerConn.serverProperties.topicAliasMaximum) {
|
||||
topicOK = typeof msg.topicAlias === "number" && msg.topicAlias >= 0 && node.brokerConn.serverProperties.topicAliasMaximum >= msg.topicAlias
|
||||
msg.topic = "";//must be empty string?
|
||||
if (!topicOK && v5) {
|
||||
if (msg.hasOwnProperty("topicAlias") && typeof msg.topicAlias === "number" && msg.topicAlias >= 0 && node.brokerConn.serverProperties.topicAliasMaximum && node.brokerConn.serverProperties.topicAliasMaximum >= msg.topicAlias) {
|
||||
topicOK = true;
|
||||
msg.topic = ""; //must be empty string
|
||||
} else if (msg.hasOwnProperty("responseTopic") && (typeof msg.responseTopic === "string") && (msg.responseTopic !== "")) {
|
||||
topicOK = true;
|
||||
msg.topic = msg.responseTopic;
|
||||
}
|
||||
}
|
||||
if (topicOK) { // topic must exist
|
||||
debug(`MQTTOutNode:${node.id}: sending msg to ${msg.topic}`, msg);
|
||||
|
Loading…
Reference in New Issue
Block a user