From 07dc35f3ac981e479cf67c8e626650b98d24c5b3 Mon Sep 17 00:00:00 2001 From: ChrisChrome Date: Sat, 21 Jun 2025 00:37:55 -0600 Subject: [PATCH] Guh --- index.js | 34 ++++++++++++++++++++++++++-------- 1 file changed, 26 insertions(+), 8 deletions(-) diff --git a/index.js b/index.js index 0218c8a..a76e48f 100644 --- a/index.js +++ b/index.js @@ -1,4 +1,4 @@ -require('dotenv').config({override: true}); +require('dotenv').config({ override: true }); const config = require("./config.json"); const express = require('express'); const expressWs = require('express-ws'); @@ -46,12 +46,12 @@ app.get("/", (req, res) => { const htmlContent = markdown.render(data); - res.render('docViewer', {title: 'Websocket Docs', htmlContent: htmlContent}); + res.render('docViewer', { title: 'Websocket Docs', htmlContent: htmlContent }); }); }); -app.use('/event-logs', - serveIndex(path.join(__dirname, 'event-logs'), { icons: true, view: 'details' }), +app.use('/event-logs', + serveIndex(path.join(__dirname, 'event-logs'), { icons: true, view: , hidden: true }), express.static(path.join(__dirname, 'event-logs')) ); @@ -152,7 +152,7 @@ app.ws('/iem', (ws, req) => { } })); break; - } else if(!roomList.includes(subscriptionTarget)) { + } else if (!roomList.includes(subscriptionTarget)) { ws.send(JSON.stringify({ "type": "internal-response", "code": 404, @@ -184,7 +184,7 @@ app.ws('/iem', (ws, req) => { } })); break; - } else if(!getWFO(data.channel)) { + } else if (!getWFO(data.channel)) { ws.send(JSON.stringify({ "type": "internal-response", "code": 404, @@ -232,7 +232,7 @@ app.ws('/iem', (ws, req) => { })); } break; - case "ping": + case "ping": ws.send(JSON.stringify({ "type": "internal-response", "code": 200, @@ -481,7 +481,6 @@ xmpp.on("stanza", (stanza) => { return value; }; }; - fs.writeFileSync(logPath, JSON.stringify({evt, stanza, product_id, product_id_raw, bodyData, body}, getCircularReplacer(), 2), 'utf8'); if (!evt) { evt = { name: "Unknown", priority: 3 } @@ -568,6 +567,25 @@ xmpp.on("stanza", (stanza) => { } }) }); + fs.writeFileSync(logPath, JSON.stringify({ + evt, stanza, product_id, product_id_raw, bodyData, body, sentData: { + "type": "iem-message", + "data": { + "channel": getWFOByRoom(fromChannel), + "event": evt, + "body": bodyData, + "timestamp": product_id.timestamp, + "wmo": product_id.wmo, + "pil": product_id.pil, + "station": product_id.station, + "product_data": product_id, + "raw": product_id_raw, + "rawBody": body, + "image": stanza.getChild("x").attrs.twitter_media || null, + "productText": text || null + } + } + }, getCircularReplacer(), 2), 'utf8'); } tryGetText(); }