mirror of
https://github.com/node-red/node-red.git
synced 2025-03-01 10:36:34 +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.protocolId; //V4+ default
|
||||||
delete node.options.protocolVersion; //V4 default
|
delete node.options.protocolVersion; //V4 default
|
||||||
delete node.options.properties;//V5 only
|
delete node.options.properties;//V5 only
|
||||||
|
|
||||||
|
|
||||||
if (node.compatmode == "true" || node.compatmode === true || node.protocolVersion == 3) {
|
if (node.compatmode == "true" || node.compatmode === true || node.protocolVersion == 3) {
|
||||||
node.options.protocolId = 'MQIsdp';//V3 compat only
|
node.options.protocolId = 'MQIsdp';//V3 compat only
|
||||||
node.options.protocolVersion = 3;
|
node.options.protocolVersion = 3;
|
||||||
@ -691,6 +693,21 @@ module.exports = function(RED) {
|
|||||||
setIntProp(node,node.options.properties,"sessionExpiryInterval");
|
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) {
|
if (node.usetls && n.tls) {
|
||||||
var tlsNode = RED.nodes.getNode(n.tls);
|
var tlsNode = RED.nodes.getNode(n.tls);
|
||||||
if (tlsNode) {
|
if (tlsNode) {
|
||||||
|
Loading…
x
Reference in New Issue
Block a user