core: status: auto-remove after 24hr

This commit is contained in:
undefined committed 2021-04-05 17:49:12 +08:00
1 parent 9524e56d01
commit 4904b16fa5
3 files changed
+6 -2

No files matched your search

+4
View File
@@ -3,6 +3,7 @@ import RecordModel from '../model/record';
import DomainModel from '../model/domain';
import * as DocumentModel from '../model/document';
import db from '../service/db';
import * as bus from '../service/bus';
import { Route, Handler } from '../service/server';
import UserModel from '../model/user';
@@ -64,6 +65,7 @@ class StatusUpdateHandler extends Handler {
async post(args) {
this.checkPriv(PRIV.PRIV_JUDGE);
args.type = 'judge';
args.updateAt = new Date();
return coll.updateOne(
{ mid: args.mid, type: 'judge' },
{ $set: args },
@@ -72,6 +74,8 @@ class StatusUpdateHandler extends Handler {
}
}
bus.once('app/started', () => coll.createIndex('updateAt', { expireAfterSeconds: 24 * 3600 }));
export async function apply() {
Route('status', '/status', StatusHandler);
Route('status_admin', '/.status', AdminStatusHandler);