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

Bugfix: not responsive to msg.topic on input of STOMP out node

This commit is contained in:
Olivier Verhaegen 2023-06-07 14:16:57 +02:00 committed by GitHub
parent 983cab970e
commit 55ba9c89ed
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23

View File

@ -420,15 +420,21 @@ module.exports = function(RED) {
setStatusDisconnected(node); setStatusDisconnected(node);
node.on("input", function(msg, send, done) { node.on("input", function(msg, send, done) {
if (node.topic && msg.payload) { const topic = msg.topic || node.topic;
if (topic.length > 0 && msg.payload) {
try { try {
msg.payload = JSON.stringify(msg.payload); msg.payload = JSON.stringify(msg.payload);
} catch { } catch {
msg.payload = `${msg.payload}`; msg.payload = `${msg.payload}`;
} }
node.serverConnection.publish(node.topic, msg.payload, msg.headers || {}); node.serverConnection.publish(node.topic, msg.payload, msg.headers || {});
done(); } else if (!topic.length > 0) {
node.warn('No valid publish topic');
} else {
node.warn('Payload is undefined or null')
} }
done();
}); });
node.serverConnection.register(node); node.serverConnection.register(node);