Fix event code assignment in index.js

This commit is contained in:
Christopher Cookman 2024-05-12 08:56:42 -06:00
parent d59fdb2c5c
commit 710e4258f3
Signed by: ChrisChrome
GPG key ID: A023A26E42C33A42

View file

@ -284,12 +284,13 @@ xmpp.on("stanza", (stanza) => {
const bodyData = getFirstURL(body);
// get product id from "x" tag
var evt = events[product_id.pil.substring(0, 3)];
evt.code = product_id.pil.substring(0, 3);
if (!evt) {
evt = { name: "Unknown", priority: 3 }
console.log(`${colors.red("[ERROR]")} Unknown event type: ${product_id.pil.substring(0, 3)}. Fix me`);
}
evt.code = product_id.pil.substring(0, 3);
// Check timestamp, if not within 3 minutes, ignore it
const now = new Date();
const diff = (now - product_id.timestamp) / 1000 / 60;