From 757b40f7377109fa715cce526c7f94b50ce08e48 Mon Sep 17 00:00:00 2001 From: "Glitch (hello-express)" Date: Sun, 3 Nov 2019 23:06:02 +0000 Subject: [PATCH] =?UTF-8?q?=F0=9F=8D=8E=F0=9F=91=82=20Checkpoint=20./serve?= =?UTF-8?q?r.js:933874/6555?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- server.js | 7 ++++++- 1 file changed, 6 insertions(+), 1 deletion(-) diff --git a/server.js b/server.js index 8bd42c1..1f616d0 100644 --- a/server.js +++ b/server.js @@ -63,7 +63,7 @@ app.get("/status", (req, res) => { fuzIsOpen = req.query.fuzisopen === "1"; lastSeen = new Date(); try { - fs.writeFileSync(db, JSON.stringify({ fuzIsOpen, lastSeen })); + fs.writeFileSync(db, JSON.stringify({ fuzIsOpen, lastSeen, lastClosed })); } catch (err) {} res.sendStatus(200); @@ -78,6 +78,11 @@ const loop = () => { if (lastSeen < new Date() - 2 * 60 * 1000 && lastClosed < lastSeen) { // the Fuz is newly closed, notify on matrix and write file to survive reboot 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);