Łatki bezpieczeństwa, dodana nowa sceneria do danych

This commit is contained in:
2020-08-15 13:23:02 +02:00
parent 9e3f02bfe2
commit 00ab5e9713
9 changed files with 180 additions and 138 deletions
+18 -10
View File
@@ -7,14 +7,22 @@ const db = admin.firestore();
import axios from "axios";
exports.scheduledUpdate = functions.pubsub
.schedule("5 * * * *")
.schedule("*/5 * * * *")
.onRun(async (context) => {
const stationData: {
let stationData: {
stationName: string;
dispatcherName: string;
}[] = await (
await axios.get("https://api.td2.info.pl:9640/?method=getStationsOnline")
).data.message;
}[];
try {
stationData = await (
await axios.get(
"https://api.td2.info.pl:9640/?method=getStationsOnline"
)
).data.message;
} catch (error) {
return;
}
const historyRef = db.collection("history");
@@ -28,11 +36,11 @@ exports.scheduledUpdate = functions.pubsub
currentDispatcherName: station.dispatcherName,
});
docRef.collection("dispatcherHistory").add({
dispatcherName: station.dispatcherName,
occupiedFrom: Date.now(),
occupiedTo: 0,
});
// docRef.collection("dispatcherHistory").add({
// dispatcherName: station.dispatcherName,
// occupiedFrom: Date.now(),
// occupiedTo: 0,
// });
return;
}