Changed msg structure

master
Guido Longoni 2020-08-18 11:24:32 +02:00
parent 6789484d8a
commit 2e2d3b460d
1 changed files with 7 additions and 4 deletions

View File

@ -55,10 +55,13 @@ module.exports = function(RED) {
node.status({fill:"green",shape:"dot",text:"connected"});
node.clientdb.on('notification', function(msg) {
try {
//console.log("Notification received");
msg.payload = JSON.parse(msg.payload);
//node.log(JSON.stringify(msg));
node.send(msg);
var outmsg = {};
outmsg.payload = JSON.parse(msg.payload);
delete msg.payload;
outmsg.topic = msg.channel;
delete msg.channel;
outmsg.pg_data = msg;
node.send(outmsg);
} catch (error) {
node.error(error);
}