From 3b6b6e3c17f79436d0ee8853c2e5ee1b0f805e7c Mon Sep 17 00:00:00 2001 From: undefined Date: Mon, 25 Oct 2021 11:41:15 +0800 Subject: [PATCH] core: handle referenced config --- packages/hydrooj/src/handler/contest.ts | 6 ++++-- packages/hydrooj/src/handler/homework.ts | 6 ++++-- packages/hydrooj/src/handler/problem.ts | 4 ++++ 3 files changed, 12 insertions(+), 4 deletions(-) diff --git a/packages/hydrooj/src/handler/contest.ts b/packages/hydrooj/src/handler/contest.ts index ba409b278..66001efb4 100644 --- a/packages/hydrooj/src/handler/contest.ts +++ b/packages/hydrooj/src/handler/contest.ts @@ -262,9 +262,11 @@ export class ContestProblemHandler extends Handler { if (!this.pdoc) throw new ProblemNotFoundError(domainId, pid); this.pdoc.pid = _pid; this.pdoc.tag.length = 0; - // @ts-ignore - if (this.pdoc.domainId !== domainId) this.pdoc.docId = `${this.pdoc.domainId}:${this.pdoc.docId}`; this.attended = this.tsdoc && this.tsdoc.attend === 1; + if (this.pdoc.reference) { + const pdoc = await problem.get(this.pdoc.reference.domainId, this.pdoc.reference.pid); + this.pdoc.config = pdoc.config; + } const showAccept = contest.canShowScoreboard.call(this, this.tdoc, true); if (!showAccept) this.pdoc.nAccept = 0; if (contest.isNotStarted(this.tdoc)) throw new ContestNotLiveError(tid); diff --git a/packages/hydrooj/src/handler/homework.ts b/packages/hydrooj/src/handler/homework.ts index ea0426a47..a543610e6 100644 --- a/packages/hydrooj/src/handler/homework.ts +++ b/packages/hydrooj/src/handler/homework.ts @@ -132,8 +132,10 @@ class HomeworkDetailProblemHandler extends Handler { contest.getStatus(domainId, tid, this.user._id), ]); if (!this.pdoc) throw new ProblemNotFoundError(domainId, this.pid); - // @ts-ignore - if (this.pdoc.domainId !== domainId) this.pdoc.docId = `${this.pdoc.domainId}:${this.pdoc.docId}`; + if (this.pdoc.reference) { + const pdoc = await problem.get(this.pdoc.reference.domainId, this.pdoc.reference.pid); + this.pdoc.config = pdoc.config; + } this.pdoc.pid = _pid; this.attended = this.tsdoc?.attend === 1; this.response.body = { diff --git a/packages/hydrooj/src/handler/problem.ts b/packages/hydrooj/src/handler/problem.ts index 790afce6b..664cf2ac6 100644 --- a/packages/hydrooj/src/handler/problem.ts +++ b/packages/hydrooj/src/handler/problem.ts @@ -224,6 +224,10 @@ export class ProblemDetailHandler extends ProblemHandler { problem.getStatus(domainId, this.pdoc.docId, this.user._id), user.getById(domainId, this.pdoc.owner), ]); + if (this.pdoc.reference) { + const pdoc = await problem.get(this.pdoc.reference.domainId, this.pdoc.reference.pid); + this.pdoc.config = pdoc.config; + } const [scnt, dcnt] = await Promise.all([ solution.count(domainId, { parentId: this.pdoc.docId }), discussion.count(domainId, { parentId: this.pdoc.docId }),