From 83b99ffea6ee7dccf8577b89e4018db8b8359e34 Mon Sep 17 00:00:00 2001 From: "Glitch (hello-express)" Date: Tue, 5 Nov 2019 10:15:45 +0000 Subject: [PATCH] =?UTF-8?q?=F0=9F=8F=AB=F0=9F=98=87=20Checkpoint=20./serve?= =?UTF-8?q?r.js:933874/10760?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- server.js | 11 +++++++---- 1 file changed, 7 insertions(+), 4 deletions(-) diff --git a/server.js b/server.js index 2bd6fa1..50e2472 100644 --- a/server.js +++ b/server.js @@ -108,10 +108,12 @@ request.post( const accessToken = JSON.parse(body)["access_token"]; const loop = () => { console.log("loop", lastClosed); - if (fuzIsOpen && lastSeen < new Date() - closingTimeout && lastClosed < lastSeen) { + if ( + fuzIsOpen && + lastSeen < new Date() - closingTimeout && + 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 request.put( { @@ -138,13 +140,14 @@ request.post( function(error, response, body2) { if (!error) { try { + lastClosed = new Date(); fs.writeFileSync( db, JSON.stringify({ fuzIsOpen, lastSeen, lastClosed }) ); } catch (err) {} } - console.log(body2) + console.log(body2); setTimeout(loop, 10 * 1000); } );