mirror of
https://gitcode.com/gh_mirrors/hy/Hydro.git
synced 2026-10-20 01:38:19 +08:00
bump beta.10
This commit is contained in:
27 files changed
+143
-112
No files matched your search
@@ -59,7 +59,9 @@ class ScheduleModel {
|
||||
}
|
||||
|
||||
export async function apply(ctx: Context) {
|
||||
ctx.inject(['worker'], (c) => {
|
||||
ctx.on('domain/delete', (domainId) => coll.deleteMany({ domainId }));
|
||||
|
||||
await ctx.inject(['worker'], (c) => {
|
||||
c.worker.addHandler('task.daily', async (task) => {
|
||||
const pref: Record<string, number> = {};
|
||||
let start = Date.now();
|
||||
@@ -88,8 +90,6 @@ export async function apply(ctx: Context) {
|
||||
});
|
||||
});
|
||||
|
||||
ctx.on('domain/delete', (domainId) => coll.deleteMany({ domainId }));
|
||||
|
||||
if (process.env.NODE_APP_INSTANCE !== '0') return;
|
||||
if (!await ScheduleModel.count({ type: 'schedule', subType: 'task.daily' })) {
|
||||
await ScheduleModel.add({
|
||||
|
||||
@@ -179,9 +179,6 @@ async function cleanFiles() {
|
||||
}
|
||||
|
||||
export async function apply(ctx: Context) {
|
||||
ctx.inject(['worker'], (c) => {
|
||||
c.worker.addHandler('storage.prune', cleanFiles);
|
||||
});
|
||||
ctx.on('domain/delete', async (domainId) => {
|
||||
const [problemFiles, contestFiles, trainingFiles] = await Promise.all([
|
||||
StorageModel.list(`problem/${domainId}`),
|
||||
@@ -190,6 +187,9 @@ export async function apply(ctx: Context) {
|
||||
]);
|
||||
await StorageModel.del(problemFiles.concat(contestFiles).concat(trainingFiles).map((i) => i.path));
|
||||
});
|
||||
await ctx.inject(['worker'], (c) => {
|
||||
c.worker.addHandler('storage.prune', cleanFiles);
|
||||
});
|
||||
if (process.env.NODE_APP_INSTANCE !== '0') return;
|
||||
await db.ensureIndexes(
|
||||
StorageModel.coll,
|
||||
|
||||
@@ -25,7 +25,7 @@ export interface EventMap {
|
||||
'subscription/init': (h: ConnectionHandler<Context>, privileged: boolean) => VoidReturn;
|
||||
'subscription/subscribe': (channel: string, user: User, metadata: Record<string, string>) => VoidReturn;
|
||||
'subscription/enable': (
|
||||
channel: string, h: ConnectionHandler<Context>, privileged: boolean, onDispose: (disposable: () => void) => void
|
||||
channel: string, h: ConnectionHandler<Context>, privileged: boolean, onDispose: (disposable: () => void) => void,
|
||||
) => VoidReturn;
|
||||
|
||||
'app/watch/change': (path: string) => VoidReturn;
|
||||
@@ -61,7 +61,7 @@ export interface EventMap {
|
||||
'document/add': (doc: any) => VoidReturn;
|
||||
'document/set': <T extends keyof DocType>(
|
||||
domainId: string, docType: T, docId: DocType[T],
|
||||
$set: any, $unset: OnlyFieldsOfType<DocType[T], any, true | '' | 1>
|
||||
$set: any, $unset: OnlyFieldsOfType<DocType[T], any, true | '' | 1>,
|
||||
) => VoidReturn;
|
||||
|
||||
'discussion/before-add': (payload: Partial<DiscussionDoc>) => VoidReturn;
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
import type { KoaContext } from '@hydrooj/framework';
|
||||
import { PERM } from '../../model/builtin';
|
||||
import { PERM, PRIV } from '../../model/builtin';
|
||||
import UserModel from '../../model/user';
|
||||
|
||||
export default async (ctx: KoaContext, next) => {
|
||||
@@ -13,6 +13,9 @@ export default async (ctx: KoaContext, next) => {
|
||||
user = await UserModel.getById(domainId, ctx.session.uid, ctx.session.scope);
|
||||
}
|
||||
if (user._id === 0) delete user.viewLang;
|
||||
else if (!user._udoc.ip.includes(ctx.request.ip) && user.hasPriv(PRIV.PRIV_USER_PROFILE)) {
|
||||
await UserModel.setById(user._id, { loginip: ctx.request.ip });
|
||||
}
|
||||
ctx.HydroContext.user = await user.private();
|
||||
await next();
|
||||
};
|
||||
@@ -24,7 +24,7 @@ export default class MigrationService extends Service {
|
||||
}
|
||||
|
||||
async registerChannel(name: string, s: MigrationScript[]) {
|
||||
if (this.called) logger.warn('MigrationService.registerChannel: called after doUpgrade');
|
||||
if (this.called) logger.warn('MigrationService.registerChannel: called after doUpgrade with name: %s', name);
|
||||
this.channels[name] = s;
|
||||
}
|
||||
|
||||
|
||||
Reference in new issue
Block a user