core: add contest/before-edit

This commit is contained in:
undefined committed 2025-10-17 19:07:25 +08:00
1 parent f5ef8b7f38
commit 2858e96414
2 files changed
+2

No files matched your search

+1
View File
@@ -824,6 +824,7 @@ export async function edit(domainId: string, tid: ObjectId, $set: Partial<Tdoc>)
if ($set.rule && !RULES[$set.rule]) throw new ValidationError('rule');
const tdoc = await document.get(domainId, document.TYPE_CONTEST, tid);
if (!tdoc) throw new ContestNotFoundError(domainId, tid);
await bus.parallel('contest/before-edit', tdoc, $set);
RULES[$set.rule || tdoc.rule].check(Object.assign(tdoc, $set));
const res = await document.set(domainId, document.TYPE_CONTEST, tid, $set);
await bus.parallel('contest/edit', res);
+1
View File
@@ -85,6 +85,7 @@ export interface EventMap {
'contest/before-add': (payload: Partial<Tdoc>) => VoidReturn;
'contest/add': (payload: Partial<Tdoc>, id: ObjectId) => VoidReturn;
'contest/before-edit': (tdoc: Tdoc, $set: Partial<Tdoc>) => VoidReturn;
'contest/edit': (payload: Tdoc) => VoidReturn;
'contest/list': (query: Filter<Tdoc>, handler: any) => VoidReturn;
'contest/scoreboard': (tdoc: Tdoc, rows: ScoreboardRow[], udict: BaseUserDict, pdict: ProblemDict) => VoidReturn;