mirror of
				https://github.com/node-red/node-red-nodes.git
				synced 2025-03-01 10:37:43 +00:00 
			
		
		
		
	STOMP bugfix: msg.topic can't be used with STOMP out node and ack node (#1009)
* Bugfix: not responsive to msg.topic on input of STOMP out node * Bugfix: not responsive to msg.topic on input of STOMP ack and out node * Bugfix: backward compatible node.topic has prio + Docs: added info about msg.topic in ACK node docs * Typo fix
This commit is contained in:
		
				
					committed by
					
						 GitHub
						GitHub
					
				
			
			
				
	
			
			
			
						parent
						
							983cab970e
						
					
				
				
					commit
					8743c2afa6
				
			| @@ -197,6 +197,7 @@ | ||||
|     <p> | ||||
|         The node allows for following inputs: | ||||
|         <ul> | ||||
|             <li><code>msg.topic</code>The topic for which the message should be acknowledged, if the <b>Destination</b> field is set the msg.topic will be overwritten by this value</li> | ||||
|             <li><code>msg.messageId</code>: The id of the message to acknowledge</li> | ||||
|             <li><code>msg.transaction</code>: Optional transaction name</li> | ||||
|         </ul> | ||||
|   | ||||
| @@ -420,15 +420,21 @@ module.exports = function(RED) { | ||||
|             setStatusDisconnected(node); | ||||
|  | ||||
|             node.on("input", function(msg, send, done) { | ||||
|                 if (node.topic && msg.payload) { | ||||
|                 const topic = node.topic || msg.topic; | ||||
|                 if (topic.length > 0 && msg.payload) { | ||||
|                     try { | ||||
|                         msg.payload = JSON.stringify(msg.payload); | ||||
|                     } catch { | ||||
|                         msg.payload = `${msg.payload}`; | ||||
|                     } | ||||
|                     node.serverConnection.publish(node.topic, msg.payload, msg.headers || {}); | ||||
|                     done(); | ||||
|                     node.serverConnection.publish(topic, msg.payload, msg.headers || {}); | ||||
|                 } else if (!topic.length > 0) { | ||||
|                     node.warn('No valid publish topic'); | ||||
|  | ||||
|                 } else { | ||||
|                     node.warn('Payload or topic is undefined/null') | ||||
|                 } | ||||
|                 done(); | ||||
|             }); | ||||
|  | ||||
|             node.serverConnection.register(node); | ||||
| @@ -463,7 +469,15 @@ module.exports = function(RED) { | ||||
|             setStatusDisconnected(node); | ||||
|  | ||||
|             node.on("input", function(msg, send, done) { | ||||
|                 node.serverConnection.ack(node.topic, msg.messageId, msg.transaction); | ||||
|                 const topic = node.topic || msg.topic; | ||||
|                 if (topic.length > 0) { | ||||
|                     node.serverConnection.ack(topic, msg.messageId, msg.transaction); | ||||
|                 } else if (!topic.length > 0) { | ||||
|                     node.warn('No valid publish topic'); | ||||
|  | ||||
|                 } else { | ||||
|                     node.warn('Payload or topic is undefined/null') | ||||
|                 } | ||||
|                 done(); | ||||
|             }); | ||||
|  | ||||
|   | ||||
		Reference in New Issue
	
	Block a user