mirror of
https://github.com/node-red/node-red
synced 2024-11-21 23:48:30 +00:00
Ensure will payload is a string
This commit is contained in:
parent
edc01552f9
commit
7f77a414ec
@ -673,6 +673,8 @@ module.exports = function(RED) {
|
||||
delete node.options.protocolId; //V4+ default
|
||||
delete node.options.protocolVersion; //V4 default
|
||||
delete node.options.properties;//V5 only
|
||||
|
||||
|
||||
if (node.compatmode == "true" || node.compatmode === true || node.protocolVersion == 3) {
|
||||
node.options.protocolId = 'MQIsdp';//V3 compat only
|
||||
node.options.protocolVersion = 3;
|
||||
@ -691,6 +693,21 @@ module.exports = function(RED) {
|
||||
setIntProp(node,node.options.properties,"sessionExpiryInterval");
|
||||
}
|
||||
}
|
||||
// Ensure will payload, if set, is a string
|
||||
if (node.options.will && Object.hasOwn(node.options.will, 'payload')) {
|
||||
let payload = node.options.will.payload
|
||||
if (payload === null || payload === undefined) {
|
||||
payload = "";
|
||||
} else if (!Buffer.isBuffer(payload)) {
|
||||
if (typeof payload === "object") {
|
||||
payload = JSON.stringify(payload);
|
||||
} else if (typeof payload !== "string") {
|
||||
payload = "" + payload;
|
||||
}
|
||||
}
|
||||
node.options.will.payload = payload
|
||||
}
|
||||
|
||||
if (node.usetls && n.tls) {
|
||||
var tlsNode = RED.nodes.getNode(n.tls);
|
||||
if (tlsNode) {
|
||||
|
Loading…
Reference in New Issue
Block a user