mirror of
https://github.com/Lomanic/presence-button-web
synced 2024-11-22 13:37:29 +00:00
🍎👂 Checkpoint
./server.js:933874/6555
This commit is contained in:
parent
647bfe55a4
commit
757b40f737
@ -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);
|
||||||
|
Loading…
Reference in New Issue
Block a user