diff --git a/packages/hydrooj/package.json b/packages/hydrooj/package.json index 233ffeed2..9a5fb1500 100644 --- a/packages/hydrooj/package.json +++ b/packages/hydrooj/package.json @@ -1,6 +1,6 @@ { "name": "hydrooj", - "version": "2.29.12", + "version": "2.29.13", "bin": "bin/hydrooj.js", "main": "dist/loader.js", "typings": "dist/loader.d.ts", diff --git a/packages/hydrooj/src/handler/home.ts b/packages/hydrooj/src/handler/home.ts index 73c366f53..385aef390 100644 --- a/packages/hydrooj/src/handler/home.ts +++ b/packages/hydrooj/src/handler/home.ts @@ -287,7 +287,7 @@ class HomeDomainHandler extends Handler { ['Hydro', 'homepage'], ['home_domain', null], ]; - let ddocs: DomainDoc[]; + let ddocs: DomainDoc[] = []; let dudict: Record = {}; if (!this.user.hasPriv(PRIV.PRIV_VIEW_ALL_DOMAIN)) { dudict = await domain.getDictUserByDomainId(this.user._id); diff --git a/packages/hydrooj/src/handler/homework.ts b/packages/hydrooj/src/handler/homework.ts index e4953fc16..7e934395f 100644 --- a/packages/hydrooj/src/handler/homework.ts +++ b/packages/hydrooj/src/handler/homework.ts @@ -132,13 +132,14 @@ class HomeworkDetailProblemHandler extends Handler { this.tdoc = await contest.get(domainId, tid, document.TYPE_HOMEWORK); const pid = this.tdoc.pids[parseInt(_pid, 36) - 10]; if (!pid) throw new ProblemNotFoundError(domainId, tid, _pid); - const pdomainId = typeof pid === 'string' ? pid.split(':')[0] : domainId; - const ppid = typeof pid === 'number' ? pid : +pid.split(':')[1]; [this.udoc, this.pdoc, this.tsdoc] = await Promise.all([ user.getById(domainId, this.tdoc.owner), - problem.get(pdomainId, ppid), + problem.get(domainId, pid), contest.getStatus(domainId, tid, this.user._id, document.TYPE_HOMEWORK), ]); + if (!this.pdoc) throw new ProblemNotFoundError(domainId, pid); + // @ts-ignore + if (this.pdoc.domainId !== domainId) this.pdoc.docId = `${this.pdoc.domainId}:${this.pdoc.docId}`; this.pdoc.pid = _pid; this.attended = this.tsdoc && this.tsdoc.attend === 1; this.response.body = {