Guh
This commit is contained in:
parent
203629639f
commit
07dc35f3ac
30
index.js
30
index.js
|
@ -1,4 +1,4 @@
|
||||||
require('dotenv').config({override: true});
|
require('dotenv').config({ override: true });
|
||||||
const config = require("./config.json");
|
const config = require("./config.json");
|
||||||
const express = require('express');
|
const express = require('express');
|
||||||
const expressWs = require('express-ws');
|
const expressWs = require('express-ws');
|
||||||
|
@ -46,12 +46,12 @@ app.get("/", (req, res) => {
|
||||||
|
|
||||||
const htmlContent = markdown.render(data);
|
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',
|
app.use('/event-logs',
|
||||||
serveIndex(path.join(__dirname, 'event-logs'), { icons: true, view: 'details' }),
|
serveIndex(path.join(__dirname, 'event-logs'), { icons: true, view: , hidden: true }),
|
||||||
express.static(path.join(__dirname, 'event-logs'))
|
express.static(path.join(__dirname, 'event-logs'))
|
||||||
);
|
);
|
||||||
|
|
||||||
|
@ -152,7 +152,7 @@ app.ws('/iem', (ws, req) => {
|
||||||
}
|
}
|
||||||
}));
|
}));
|
||||||
break;
|
break;
|
||||||
} else if(!roomList.includes(subscriptionTarget)) {
|
} else if (!roomList.includes(subscriptionTarget)) {
|
||||||
ws.send(JSON.stringify({
|
ws.send(JSON.stringify({
|
||||||
"type": "internal-response",
|
"type": "internal-response",
|
||||||
"code": 404,
|
"code": 404,
|
||||||
|
@ -184,7 +184,7 @@ app.ws('/iem', (ws, req) => {
|
||||||
}
|
}
|
||||||
}));
|
}));
|
||||||
break;
|
break;
|
||||||
} else if(!getWFO(data.channel)) {
|
} else if (!getWFO(data.channel)) {
|
||||||
ws.send(JSON.stringify({
|
ws.send(JSON.stringify({
|
||||||
"type": "internal-response",
|
"type": "internal-response",
|
||||||
"code": 404,
|
"code": 404,
|
||||||
|
@ -481,7 +481,6 @@ xmpp.on("stanza", (stanza) => {
|
||||||
return value;
|
return value;
|
||||||
};
|
};
|
||||||
};
|
};
|
||||||
fs.writeFileSync(logPath, JSON.stringify({evt, stanza, product_id, product_id_raw, bodyData, body}, getCircularReplacer(), 2), 'utf8');
|
|
||||||
|
|
||||||
if (!evt) {
|
if (!evt) {
|
||||||
evt = { name: "Unknown", priority: 3 }
|
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();
|
tryGetText();
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in a new issue