don't care if updating mqtt timestamp fails

This commit is contained in:
liamcottle
2024-08-28 20:42:24 +12:00
parent 485621ffa4
commit d163c84450

View File

@ -604,6 +604,7 @@ client.on("connect", () => {
// handle message received // handle message received
client.on("message", async (topic, message) => { client.on("message", async (topic, message) => {
try { try {
// decode service envelope // decode service envelope
const envelope = ServiceEnvelope.decode(message); const envelope = ServiceEnvelope.decode(message);
if(!envelope.packet){ if(!envelope.packet){
@ -630,15 +631,19 @@ client.on("message", async (topic, message) => {
} }
} }
// Update Node MQTT status based on Last Packet Received time // track when a node last gated a packet to mqtt
await prisma.node.updateMany({ try {
where: { await prisma.node.updateMany({
node_id: convertHexIdToNumericId(envelope.gatewayId), where: {
}, node_id: convertHexIdToNumericId(envelope.gatewayId),
data: { },
mqtt_connection_state_updated_at: new Date(), data: {
}, mqtt_connection_state_updated_at: new Date(),
}); },
});
} catch(e) {
// don't care if updating mqtt timestamp fails
}
// attempt to decrypt encrypted packets // attempt to decrypt encrypted packets
const isEncrypted = envelope.packet.encrypted?.length > 0; const isEncrypted = envelope.packet.encrypted?.length > 0;