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

Merge pull request #2886 from Steve-Mcl/dev

mqtt v5 fixes
This commit is contained in:
Nick O'Leary 2021-03-01 11:56:00 +00:00 committed by GitHub
commit f69d6b4eb1
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23

View File

@ -188,7 +188,7 @@ module.exports = function(RED) {
setStrProp(n.birthMsg, this.birthMessage, "contentType"); setStrProp(n.birthMsg, this.birthMessage, "contentType");
if(n.birthMsg.userProps && /^ *{/.test(n.birthMsg.userProps)) { if(n.birthMsg.userProps && /^ *{/.test(n.birthMsg.userProps)) {
try { try {
this.birthMessage.userProperties = JSON.parse(n.birthMsg.userProps) setUserProperties(JSON.parse(n.birthMsg.userProps), this.birthMessage);
} catch(err) {} } catch(err) {}
} }
n.birthMsg.responseTopic = n.birthMsg.respTopic; n.birthMsg.responseTopic = n.birthMsg.respTopic;
@ -196,7 +196,7 @@ module.exports = function(RED) {
n.birthMsg.correlationData = n.birthMsg.correl; n.birthMsg.correlationData = n.birthMsg.correl;
setBufferProp(n.birthMsg, this.birthMessage, "correlationData"); setBufferProp(n.birthMsg, this.birthMessage, "correlationData");
n.birthMsg.messageExpiryInterval = n.birthMsg.expiry n.birthMsg.messageExpiryInterval = n.birthMsg.expiry
setIntProp(n.willMsg,this.birthMessage, "messageExpiryInterval") setIntProp(n.birthMsg,this.birthMessage, "messageExpiryInterval")
} }
} }
@ -212,7 +212,7 @@ module.exports = function(RED) {
setStrProp(n.closeMsg, this.closeMessage, "contentType"); setStrProp(n.closeMsg, this.closeMessage, "contentType");
if(n.closeMsg.userProps && /^ *{/.test(n.closeMsg.userProps)) { if(n.closeMsg.userProps && /^ *{/.test(n.closeMsg.userProps)) {
try { try {
this.closeMessage.userProperties = JSON.parse(n.closeMsg.userProps) setUserProperties(JSON.parse(n.closeMsg.userProps), this.closeMessage);
} catch(err) {} } catch(err) {}
} }
n.closeMsg.responseTopic = n.closeMsg.respTopic; n.closeMsg.responseTopic = n.closeMsg.respTopic;
@ -220,7 +220,7 @@ module.exports = function(RED) {
n.closeMsg.correlationData = n.closeMsg.correl; n.closeMsg.correlationData = n.closeMsg.correl;
setBufferProp(n.closeMsg, this.closeMessage, "correlationData"); setBufferProp(n.closeMsg, this.closeMessage, "correlationData");
n.closeMsg.messageExpiryInterval = n.closeMsg.expiry n.closeMsg.messageExpiryInterval = n.closeMsg.expiry
setIntProp(n.willMsg,this.closeMessage, "messageExpiryInterval") setIntProp(n.birthMsg,this.closeMessage, "messageExpiryInterval")
} }
} }
@ -365,7 +365,7 @@ module.exports = function(RED) {
setStrProp(n.willMsg, this.options.will.properties, "contentType"); setStrProp(n.willMsg, this.options.will.properties, "contentType");
if(n.willMsg.userProps && /^ *{/.test(n.willMsg.userProps)) { if(n.willMsg.userProps && /^ *{/.test(n.willMsg.userProps)) {
try { try {
this.options.will.properties.userProperties = JSON.parse(n.willMsg.userProps) setUserProperties(JSON.parse(n.willMsg.userProps), this.options.will.properties);
} catch(err) {} } catch(err) {}
} }
n.willMsg.responseTopic = n.willMsg.respTopic; n.willMsg.responseTopic = n.willMsg.respTopic;
@ -612,9 +612,6 @@ module.exports = function(RED) {
setBufferProp(msg, options.properties, "correlationData"); setBufferProp(msg, options.properties, "correlationData");
setStrProp(msg, options.properties, "contentType"); setStrProp(msg, options.properties, "contentType");
setIntProp(msg, options.properties, "messageExpiryInterval", 0); setIntProp(msg, options.properties, "messageExpiryInterval", 0);
if (msg.userProperties) {
options.properties.userProperties = msg.userProperties;
}
setUserProperties(msg.userProperties, options.properties); setUserProperties(msg.userProperties, options.properties);
setIntProp(msg, options.properties, "topicAlias", 1, node.serverProperties.topicAliasMaximum || 0); setIntProp(msg, options.properties, "topicAlias", 1, node.serverProperties.topicAliasMaximum || 0);
setBoolProp(msg, options.properties, "payloadFormatIndicator"); setBoolProp(msg, options.properties, "payloadFormatIndicator");
@ -774,7 +771,8 @@ module.exports = function(RED) {
this.messageExpiryInterval = n.expiry; //https://docs.oasis-open.org/mqtt/mqtt/v5.0/os/mqtt-v5.0-os.html#_Toc3901112 this.messageExpiryInterval = n.expiry; //https://docs.oasis-open.org/mqtt/mqtt/v5.0/os/mqtt-v5.0-os.html#_Toc3901112
try { try {
if (/^ *{/.test(n.userProps)) { if (/^ *{/.test(n.userProps)) {
this.userProperties = JSON.parse(n.userProps);//https://docs.oasis-open.org/mqtt/mqtt/v5.0/os/mqtt-v5.0-os.html#_Toc3901116 //setup this.userProperties
setUserProperties(JSON.parse(n.userProps), this);//https://docs.oasis-open.org/mqtt/mqtt/v5.0/os/mqtt-v5.0-os.html#_Toc3901116
} }
} catch(err) {} } catch(err) {}
// this.topicAlias = n.topicAlias; //https://docs.oasis-open.org/mqtt/mqtt/v5.0/os/mqtt-v5.0-os.html#_Toc3901113 // this.topicAlias = n.topicAlias; //https://docs.oasis-open.org/mqtt/mqtt/v5.0/os/mqtt-v5.0-os.html#_Toc3901113