From 662a44fccf26c19d0552756963ea276eef028d00 Mon Sep 17 00:00:00 2001 From: Stephen McLaughlin <44235289+Steve-Mcl@users.noreply.github.com> Date: Fri, 29 Apr 2022 10:44:19 +0100 Subject: [PATCH 1/2] save and restore v5 config user props --- .../node_modules/@node-red/nodes/core/network/10-mqtt.html | 5 +++++ 1 file changed, 5 insertions(+) diff --git a/packages/node_modules/@node-red/nodes/core/network/10-mqtt.html b/packages/node_modules/@node-red/nodes/core/network/10-mqtt.html index 747281ad0..cf4015f2e 100644 --- a/packages/node_modules/@node-red/nodes/core/network/10-mqtt.html +++ b/packages/node_modules/@node-red/nodes/core/network/10-mqtt.html @@ -609,6 +609,7 @@ default: !this.userProps ? 'none':'json', types: [typedInputNoneOpt, 'json'] }); + $("#node-config-input-userProps").typedInput('value',this.userProps); if (typeof this.keepalive === 'undefined') { this.keepalive = 15; $("#node-config-input-keepalive").val(this.keepalive); @@ -718,6 +719,10 @@ } if (v5) { + const userProps = $("#node-config-input-userProps").val().trim(); + if (userProps) { + this.userProps = userProps; + } this.birthMsg = saveV5Message("birth"); this.closeMsg = saveV5Message("close"); this.willMsg = saveV5Message("will"); From 294fc6b62f8ff986ec1331f542155f44e7bf9f52 Mon Sep 17 00:00:00 2001 From: Stephen McLaughlin <44235289+Steve-Mcl@users.noreply.github.com> Date: Fri, 29 Apr 2022 11:25:19 +0100 Subject: [PATCH 2/2] Ensure userProps makes it through to runtime --- .../@node-red/nodes/core/network/10-mqtt.html | 11 ++++++++--- .../@node-red/nodes/core/network/10-mqtt.js | 8 ++++++-- 2 files changed, 14 insertions(+), 5 deletions(-) diff --git a/packages/node_modules/@node-red/nodes/core/network/10-mqtt.html b/packages/node_modules/@node-red/nodes/core/network/10-mqtt.html index cf4015f2e..ecef71366 100644 --- a/packages/node_modules/@node-red/nodes/core/network/10-mqtt.html +++ b/packages/node_modules/@node-red/nodes/core/network/10-mqtt.html @@ -480,6 +480,7 @@ willRetain: {value:false}, willPayload: {value:""}, willMsg: { value: {}}, + userProps: { value: ""}, sessionExpiry: {value:0} }, credentials: { @@ -719,9 +720,13 @@ } if (v5) { - const userProps = $("#node-config-input-userProps").val().trim(); - if (userProps) { - this.userProps = userProps; + this.userProps = ""; + const userPropsType = $("#node-config-input-userProps").typedInput("type"); + if(userPropsType == "json") { + const userProps = $("#node-config-input-userProps").val(); + if (userProps && typeof userProps === "string") { + this.userProps = userProps.trim(); + } } this.birthMsg = saveV5Message("birth"); this.closeMsg = saveV5Message("close"); diff --git a/packages/node_modules/@node-red/nodes/core/network/10-mqtt.js b/packages/node_modules/@node-red/nodes/core/network/10-mqtt.js index a026fdc29..1e8f8ce9c 100644 --- a/packages/node_modules/@node-red/nodes/core/network/10-mqtt.js +++ b/packages/node_modules/@node-red/nodes/core/network/10-mqtt.js @@ -415,8 +415,12 @@ module.exports = function(RED) { setIfHasProperty(opts, node, "topicAliasMaximum", init); setIfHasProperty(opts, node, "maximumPacketSize", init); setIfHasProperty(opts, node, "receiveMaximum", init); - setIfHasProperty(opts, node, "userProperties", init);//https://docs.oasis-open.org/mqtt/mqtt/v5.0/os/mqtt-v5.0-os.html#_Toc3901116 - setIfHasProperty(opts, node, "userPropertiesType", init); + //https://docs.oasis-open.org/mqtt/mqtt/v5.0/os/mqtt-v5.0-os.html#_Toc3901116 + if (hasProperty(opts, "userProperties")) { + node.userProperties = opts.userProperties; + } else if (hasProperty(opts, "userProps")) { + node.userProperties = opts.userProps; + } function createLWT(topic, payload, qos, retain, v5opts, v5SubPropName) { let message = undefined;