9
0
mirror of https://github.com/Lomanic/presence-button-web synced 2024-11-26 07:27:30 +00:00

🍎👂 Checkpoint

./server.js:933874/6555
This commit is contained in:
Glitch (hello-express) 2019-11-03 23:06:02 +00:00
parent 647bfe55a4
commit 757b40f737

View File

@ -63,7 +63,7 @@ app.get("/status", (req, res) => {
fuzIsOpen = req.query.fuzisopen === "1"; fuzIsOpen = req.query.fuzisopen === "1";
lastSeen = new Date(); lastSeen = new Date();
try { try {
fs.writeFileSync(db, JSON.stringify({ fuzIsOpen, lastSeen })); fs.writeFileSync(db, JSON.stringify({ fuzIsOpen, lastSeen, lastClosed }));
} catch (err) {} } catch (err) {}
res.sendStatus(200); res.sendStatus(200);
@ -78,6 +78,11 @@ const loop = () => {
if (lastSeen < new Date() - 2 * 60 * 1000 && lastClosed < lastSeen) { if (lastSeen < new Date() - 2 * 60 * 1000 && lastClosed < lastSeen) {
// the Fuz is newly closed, notify on matrix and write file to survive reboot // the Fuz is newly closed, notify on matrix and write file to survive reboot
lastClosed = new Date(); lastClosed = new Date();
//lastNofified = new Date();
//https.post ... send message to Fuz process.env.MATRIXROOM
try {
fs.writeFileSync(db, JSON.stringify({ fuzIsOpen, lastSeen, lastClosed }));
} catch (err) {}
} }
setTimeout(loop, 10 * 1000); setTimeout(loop, 10 * 1000);