From 7893ea38d7d3b4fa8607a7893f0811ded88c69be Mon Sep 17 00:00:00 2001 From: undefined Date: Fri, 17 Oct 2025 19:36:42 +0800 Subject: [PATCH] core: move problem/del to problem/delete --- packages/elastic/index.ts | 2 +- packages/hydrooj/src/handler/contest.ts | 2 +- packages/hydrooj/src/model/problem.ts | 1 - packages/hydrooj/src/service/bus.ts | 1 - packages/sonic/index.ts | 2 +- 5 files changed, 3 insertions(+), 5 deletions(-) diff --git a/packages/elastic/index.ts b/packages/elastic/index.ts index cc8e2730c..77b0bfe27 100644 --- a/packages/elastic/index.ts +++ b/packages/elastic/index.ts @@ -107,7 +107,7 @@ export default class ElasticSearchService extends Service { document: processDocument(pdoc), }); }); - this.ctx.on('problem/del', async (domainId, docId) => { + this.ctx.on('problem/delete', async (domainId, docId) => { await this.client.delete({ index: 'problem', id: `${domainId}/${docId}`, diff --git a/packages/hydrooj/src/handler/contest.ts b/packages/hydrooj/src/handler/contest.ts index b783b4694..305e0b9e8 100644 --- a/packages/hydrooj/src/handler/contest.ts +++ b/packages/hydrooj/src/handler/contest.ts @@ -636,7 +636,7 @@ export class ContestFileDownloadHandler extends ContestDetailBaseHandler { @param('noDisposition', Types.Boolean) @param('type', Types.Range(['public', 'private']), true) async get(domainId: string, tid: ObjectId, filename: string, noDisposition = false, type = 'private') { - if (type === 'private' && !this.user.own(this.tdoc)) { + if (type === 'private' && !this.user.own(this.tdoc) && !this.user.hasPerm(PERM.PERM_EDIT_CONTEST)) { if (!this.tsdoc?.attend) throw new ContestNotAttendedError(domainId, tid); if (!contest.isOngoing(this.tdoc) && !contest.isDone(this.tdoc)) throw new ContestNotLiveError(domainId, tid); if (!this.tsdoc.startAt) await contest.setStatus(domainId, tid, this.user._id, { startAt: new Date() }); diff --git a/packages/hydrooj/src/model/problem.ts b/packages/hydrooj/src/model/problem.ts index dc56c45f7..1aaebabe4 100644 --- a/packages/hydrooj/src/model/problem.ts +++ b/packages/hydrooj/src/model/problem.ts @@ -282,7 +282,6 @@ export class ProblemModel { .then((items) => storage.del(items.map((item) => `problem/${domainId}/${docId}/${item.name}`))), bus.parallel('problem/delete', domainId, docId), ]); - await bus.emit('problem/del', domainId, docId); return !!res[0][0].deletedCount; } diff --git a/packages/hydrooj/src/service/bus.ts b/packages/hydrooj/src/service/bus.ts index d4b425dd9..f7dadce44 100644 --- a/packages/hydrooj/src/service/bus.ts +++ b/packages/hydrooj/src/service/bus.ts @@ -72,7 +72,6 @@ export interface EventMap { 'problem/before-edit': (doc: Partial, $unset: OnlyFieldsOfType) => VoidReturn; 'problem/edit': (doc: ProblemDoc) => VoidReturn; 'problem/before-del': (domainId: string, docId: number) => VoidReturn; - 'problem/del': (domainId: string, docId: number) => VoidReturn; 'problem/list': (query: Filter, handler: any, sort?: string[]) => VoidReturn; 'problem/get': (doc: ProblemDoc, handler: any) => VoidReturn; 'problem/delete': (domainId: string, docId: number) => VoidReturn; diff --git a/packages/sonic/index.ts b/packages/sonic/index.ts index 71867e52b..7f51fa267 100644 --- a/packages/sonic/index.ts +++ b/packages/sonic/index.ts @@ -73,7 +73,7 @@ export class SonicService extends Service { .then(() => this.push('problem', `${pdoc.domainId}@content`, id, pdoc.content.toString())), ]).catch((e) => logger.error(e)); }); - yield this.ctx.on('problem/del', async (domainId, docId) => { + yield this.ctx.on('problem/delete', async (domainId, docId) => { const id = `${domainId}/${docId}`; await Promise.all([ this.flusho('problem', `${domainId}@title`, id),