v.1.4.3/api update

This commit is contained in:
2020-07-16 16:13:22 -04:00
parent a80a8673ff
commit 19a7adf62c
29 changed files with 176 additions and 695 deletions
+15 -6
View File
@@ -1,5 +1,13 @@
const admin = require('firebase-admin');
const FunctionModules = require('./index');
const cleanUpRoom = require('./cleanUpRoom');
const timeDiff = (ds1, ds2) => {
const d1 = new Date(ds1);
const d2 = new Date(ds2);
var diff = (d2.getTime() - d1.getTime()) / 1000;
diff /= 60 * 60;
return Math.abs(Math.round(diff));
};
module.exports = async () => {
const startedTime = new Date();
@@ -19,11 +27,12 @@ module.exports = async () => {
.get()
.then(async (roomSnap) => {
if (
FunctionModules.timeDiff(roomSnap.createTime.toDate(), startedTime) >= 24 ||
FunctionModules.timeDiff(roomSnap.updateTime.toDate(), startedTime) >= 12
)
await FunctionModules.cleanUpRoom(roomSnap.id);
console.info(`Deleted room ${roomSnap.id} from auto cleanup`);
timeDiff(roomSnap.createTime.toDate(), startedTime) >= 24 ||
timeDiff(roomSnap.updateTime.toDate(), startedTime) >= 12
) {
await cleanUpRoom(roomSnap.id);
console.info(`Deleted room ${roomSnap.id} from auto cleanup`);
}
return;
})
.catch((err) => {