Guh
This commit is contained in:
parent
203629639f
commit
07dc35f3ac
34
index.js
34
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();
|
||||
}
|
||||
|
|
Loading…
Reference in a new issue