Ensure userProps makes it through to runtime

This commit is contained in:
Stephen McLaughlin 2022-04-29 11:25:19 +01:00 committed by GitHub
parent 662a44fccf
commit 294fc6b62f
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
2 changed files with 14 additions and 5 deletions

View File

@ -480,6 +480,7 @@
willRetain: {value:false}, willRetain: {value:false},
willPayload: {value:""}, willPayload: {value:""},
willMsg: { value: {}}, willMsg: { value: {}},
userProps: { value: ""},
sessionExpiry: {value:0} sessionExpiry: {value:0}
}, },
credentials: { credentials: {
@ -719,9 +720,13 @@
} }
if (v5) { if (v5) {
const userProps = $("#node-config-input-userProps").val().trim(); this.userProps = "";
if (userProps) { const userPropsType = $("#node-config-input-userProps").typedInput("type");
this.userProps = userProps; if(userPropsType == "json") {
const userProps = $("#node-config-input-userProps").val();
if (userProps && typeof userProps === "string") {
this.userProps = userProps.trim();
}
} }
this.birthMsg = saveV5Message("birth"); this.birthMsg = saveV5Message("birth");
this.closeMsg = saveV5Message("close"); this.closeMsg = saveV5Message("close");

View File

@ -415,8 +415,12 @@ module.exports = function(RED) {
setIfHasProperty(opts, node, "topicAliasMaximum", init); setIfHasProperty(opts, node, "topicAliasMaximum", init);
setIfHasProperty(opts, node, "maximumPacketSize", init); setIfHasProperty(opts, node, "maximumPacketSize", init);
setIfHasProperty(opts, node, "receiveMaximum", 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 //https://docs.oasis-open.org/mqtt/mqtt/v5.0/os/mqtt-v5.0-os.html#_Toc3901116
setIfHasProperty(opts, node, "userPropertiesType", init); 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) { function createLWT(topic, payload, qos, retain, v5opts, v5SubPropName) {
let message = undefined; let message = undefined;