mirror of
https://github.com/Lomanic/presence-button-web
synced 2024-11-26 07:27:30 +00:00
🏫😇 Checkpoint
./server.js:933874/10760
This commit is contained in:
parent
f35b91eb2e
commit
83b99ffea6
11
server.js
11
server.js
@ -108,10 +108,12 @@ request.post(
|
|||||||
const accessToken = JSON.parse(body)["access_token"];
|
const accessToken = JSON.parse(body)["access_token"];
|
||||||
const loop = () => {
|
const loop = () => {
|
||||||
console.log("loop", lastClosed);
|
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
|
// 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
|
//https.post ... send message to Fuz process.env.MATRIXROOM
|
||||||
request.put(
|
request.put(
|
||||||
{
|
{
|
||||||
@ -138,13 +140,14 @@ request.post(
|
|||||||
function(error, response, body2) {
|
function(error, response, body2) {
|
||||||
if (!error) {
|
if (!error) {
|
||||||
try {
|
try {
|
||||||
|
lastClosed = new Date();
|
||||||
fs.writeFileSync(
|
fs.writeFileSync(
|
||||||
db,
|
db,
|
||||||
JSON.stringify({ fuzIsOpen, lastSeen, lastClosed })
|
JSON.stringify({ fuzIsOpen, lastSeen, lastClosed })
|
||||||
);
|
);
|
||||||
} catch (err) {}
|
} catch (err) {}
|
||||||
}
|
}
|
||||||
console.log(body2)
|
console.log(body2);
|
||||||
setTimeout(loop, 10 * 1000);
|
setTimeout(loop, 10 * 1000);
|
||||||
}
|
}
|
||||||
);
|
);
|
||||||
|
Loading…
Reference in New Issue
Block a user