Fixed device reporting
This commit is contained in:
+20
-19
@@ -1,5 +1,6 @@
|
|||||||
const express = require('express');
|
const express = require('express');
|
||||||
const WebSocket = require('ws');
|
const WebSocket = require('ws');
|
||||||
|
const os = require('os');
|
||||||
const { createHash } = require('crypto');
|
const { createHash } = require('crypto');
|
||||||
|
|
||||||
// TODO: make the code more reusable between the two endpoints
|
// TODO: make the code more reusable between the two endpoints
|
||||||
@@ -96,6 +97,22 @@ const hazeTranslator = {
|
|||||||
]
|
]
|
||||||
};
|
};
|
||||||
|
|
||||||
|
const deviceInfo = {
|
||||||
|
// modelname: "GeoJSON_connector"
|
||||||
|
"event": "reportDeviceInfo_request",
|
||||||
|
"body": [
|
||||||
|
"third-party",
|
||||||
|
"Linux",
|
||||||
|
"dehaze",
|
||||||
|
"Firefox",
|
||||||
|
"154.0",
|
||||||
|
"GeoJSON_connector",
|
||||||
|
null,
|
||||||
|
"desktop",
|
||||||
|
"web"
|
||||||
|
]
|
||||||
|
};
|
||||||
|
|
||||||
// Assemble full Haze location data, can take a LONG time
|
// Assemble full Haze location data, can take a LONG time
|
||||||
app.all('/locations_full.geojson', (req, res) => {
|
app.all('/locations_full.geojson', (req, res) => {
|
||||||
// TODO: Implement 1wk caching of location data
|
// TODO: Implement 1wk caching of location data
|
||||||
@@ -196,15 +213,7 @@ app.all('/locations_full.geojson', (req, res) => {
|
|||||||
haze_username = data['body']['username'];
|
haze_username = data['body']['username'];
|
||||||
// TODO: add platform report
|
// TODO: add platform report
|
||||||
haze.send(JSON.stringify({
|
haze.send(JSON.stringify({
|
||||||
"event": "reportDeviceInfo_request",
|
...deviceInfo,
|
||||||
"body": [
|
|
||||||
{
|
|
||||||
"sessionType": {
|
|
||||||
"third-party": "GeoJSON_connector",
|
|
||||||
"name": "dehaze"
|
|
||||||
}
|
|
||||||
}
|
|
||||||
],
|
|
||||||
"socketMessageId": ++hazeSocketCounter
|
"socketMessageId": ++hazeSocketCounter
|
||||||
}));
|
}));
|
||||||
} else {
|
} else {
|
||||||
@@ -364,15 +373,7 @@ app.all('/locations.geojson', (req, res) => {
|
|||||||
haze_username = data['body']['username'];
|
haze_username = data['body']['username'];
|
||||||
// TODO: add platform report
|
// TODO: add platform report
|
||||||
haze.send(JSON.stringify({
|
haze.send(JSON.stringify({
|
||||||
"event": "reportDeviceInfo_request",
|
...deviceInfo,
|
||||||
"body": [
|
|
||||||
{
|
|
||||||
"sessionType": {
|
|
||||||
"third-party": "GeoJSON_connector",
|
|
||||||
"name": "dehaze"
|
|
||||||
}
|
|
||||||
}
|
|
||||||
],
|
|
||||||
"socketMessageId": ++hazeSocketCounter
|
"socketMessageId": ++hazeSocketCounter
|
||||||
}));
|
}));
|
||||||
} else {
|
} else {
|
||||||
@@ -431,8 +432,8 @@ app.all('/locations.geojson', (req, res) => {
|
|||||||
break;
|
break;
|
||||||
default:
|
default:
|
||||||
console.dir(data);
|
console.dir(data);
|
||||||
res.status(500).send('Unexpected response from Haze API');
|
|
||||||
haze.close();
|
haze.close();
|
||||||
|
res.status(500).send('Unexpected response from Haze API');
|
||||||
res.end();
|
res.end();
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
|
|||||||
Reference in New Issue
Block a user