diff --git a/packages/node_modules/@node-red/runtime/lib/api/comms.js b/packages/node_modules/@node-red/runtime/lib/api/comms.js index 6c0d5a97a..0652a651b 100644 --- a/packages/node_modules/@node-red/runtime/lib/api/comms.js +++ b/packages/node_modules/@node-red/runtime/lib/api/comms.js @@ -38,7 +38,12 @@ function handleCommsEvent(event) { publish(event.topic,event.data,event.retain); } function handleStatusEvent(event) { - publish("status/"+event.id,event.status,true); + var status = { + text: event.status.text, + fill: event.status.fill, + shape: event.status.shape + }; + publish("status/"+event.id,status,true); } function handleRuntimeEvent(event) { runtime.log.trace("runtime event: "+JSON.stringify(event)); diff --git a/packages/node_modules/@node-red/runtime/lib/nodes/flows/Flow.js b/packages/node_modules/@node-red/runtime/lib/nodes/flows/Flow.js index 76b7fddf8..1e3352717 100644 --- a/packages/node_modules/@node-red/runtime/lib/nodes/flows/Flow.js +++ b/packages/node_modules/@node-red/runtime/lib/nodes/flows/Flow.js @@ -377,18 +377,17 @@ class Flow { return; } var message = { - status: { - text: "", - source: { - id: node.id, - type: node.type, - name: node.name - } - } - }; + status: clone(statusMessage) + } if (statusMessage.hasOwnProperty("text")) { message.status.text = statusMessage.text.toString(); } + message.status.source = { + id: node.id, + type: node.type, + name: node.name + } + targetStatusNode.receive(message); handled = true; }); diff --git a/test/unit/@node-red/runtime/lib/api/comms_spec.js b/test/unit/@node-red/runtime/lib/api/comms_spec.js index de2a6c3a4..df423b7dd 100644 --- a/test/unit/@node-red/runtime/lib/api/comms_spec.js +++ b/test/unit/@node-red/runtime/lib/api/comms_spec.js @@ -64,11 +64,14 @@ describe("runtime-api/comms", function() { eventHandlers.should.have.property('node-status'); eventHandlers['node-status']({ id: "my-event", - status: "my-status" + status: {text:"my-status",badProperty:"should be filtered"} }) messages.should.have.length(1); messages[0].should.have.property("topic","status/my-event"); - messages[0].should.have.property("data","my-status") + messages[0].should.have.property("data"); + messages[0].data.should.have.property("text","my-status"); + messages[0].data.should.not.have.property("badProperty"); + }) it('comms events',function(){ eventHandlers.should.have.property('runtime-event'); diff --git a/test/unit/@node-red/runtime/lib/nodes/flows/Flow_spec.js b/test/unit/@node-red/runtime/lib/nodes/flows/Flow_spec.js index 739836b9b..172ac11e6 100644 --- a/test/unit/@node-red/runtime/lib/nodes/flows/Flow_spec.js +++ b/test/unit/@node-red/runtime/lib/nodes/flows/Flow_spec.js @@ -498,7 +498,7 @@ describe('Flow', function() { Object.keys(activeNodes).should.have.length(5); - flow.handleStatus(config.flows["t1"].nodes["1"],{text:"my-status"}); + flow.handleStatus(config.flows["t1"].nodes["1"],{text:"my-status",random:"otherProperty"}); currentNodes["sn"].should.have.a.property("handled",1); var statusMessage = currentNodes["sn"].messages[0]; @@ -515,6 +515,7 @@ describe('Flow', function() { statusMessage.should.have.a.property("status"); statusMessage.status.should.have.a.property("text","my-status"); + statusMessage.status.should.have.a.property("random","otherProperty"); statusMessage.status.should.have.a.property("source"); statusMessage.status.source.should.have.a.property("id","1"); statusMessage.status.source.should.have.a.property("type","test");