add env var to enable and disable collecting all service envelopes
This commit is contained in:
32
src/mqtt.js
32
src/mqtt.js
@ -91,21 +91,23 @@ client.on("message", async (topic, message) => {
|
|||||||
}
|
}
|
||||||
|
|
||||||
// create service envelope in db
|
// create service envelope in db
|
||||||
try {
|
if(process.env.MM_COLLECT_SERVICE_ENVELOPES === "true"){
|
||||||
await prisma.serviceEnvelope.create({
|
try {
|
||||||
data: {
|
await prisma.serviceEnvelope.create({
|
||||||
mqtt_topic: topic,
|
data: {
|
||||||
channel_id: envelope.channelId,
|
mqtt_topic: topic,
|
||||||
gateway_id: envelope.gatewayId ? BigInt('0x' + envelope.gatewayId.replaceAll("!", "")) : null, // convert hex id "!f96a92f0" to bigint
|
channel_id: envelope.channelId,
|
||||||
to: envelope.packet.to,
|
gateway_id: envelope.gatewayId ? BigInt('0x' + envelope.gatewayId.replaceAll("!", "")) : null, // convert hex id "!f96a92f0" to bigint
|
||||||
from: envelope.packet.from,
|
to: envelope.packet.to,
|
||||||
protobuf: message,
|
from: envelope.packet.from,
|
||||||
},
|
protobuf: message,
|
||||||
});
|
},
|
||||||
} catch (e) {
|
});
|
||||||
console.error(e, {
|
} catch (e) {
|
||||||
envelope: envelope.packet,
|
console.error(e, {
|
||||||
});
|
envelope: envelope.packet,
|
||||||
|
});
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
// attempt to decrypt encrypted packets
|
// attempt to decrypt encrypted packets
|
||||||
|
Reference in New Issue
Block a user