v1.3.0-beta/release
This commit is contained in:
@@ -0,0 +1,36 @@
|
||||
const admin = require('firebase-admin');
|
||||
const FunctionModules = require('./index');
|
||||
|
||||
module.exports = async () => {
|
||||
const startedTime = new Date();
|
||||
const roomList = await admin
|
||||
.firestore()
|
||||
.collection('rooms')
|
||||
.listDocuments()
|
||||
.then((rL) => rL)
|
||||
.catch((err) => {
|
||||
console.error(
|
||||
`Failed to run auto clean up (get room list) @ ${new Date().toLocaleTimeString()}`,
|
||||
err
|
||||
);
|
||||
});
|
||||
roomList.forEach((roomRef) => {
|
||||
roomRef
|
||||
.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`);
|
||||
return;
|
||||
})
|
||||
.catch((err) => {
|
||||
console.error(
|
||||
`Failed to run auto clean up (get room snap) @ ${new Date().toLocaleTimeString()}`,
|
||||
err
|
||||
);
|
||||
});
|
||||
});
|
||||
};
|
||||
Reference in New Issue
Block a user