diff --git a/packages/hydrooj/package.json b/packages/hydrooj/package.json index f7269df8a..4934a5fc0 100644 --- a/packages/hydrooj/package.json +++ b/packages/hydrooj/package.json @@ -1,6 +1,6 @@ { "name": "hydrooj", - "version": "2.17.20", + "version": "2.17.21", "bin": "bin/hydrooj.js", "main": "dist/loader.js", "typings": "dist/loader.d.ts", diff --git a/packages/hydrooj/src/handler/problem.ts b/packages/hydrooj/src/handler/problem.ts index db629539c..1b666cf49 100644 --- a/packages/hydrooj/src/handler/problem.ts +++ b/packages/hydrooj/src/handler/problem.ts @@ -171,7 +171,9 @@ export class ProblemDetailHandler extends ProblemHandler { this.pdoc = await problem.get(domainId, pid, this.user._id); if (!this.pdoc) throw new ProblemNotFoundError(domainId, pid); if (this.pdoc.hidden && this.pdoc.owner !== this.user._id) { - this.checkPerm(PERM.PERM_VIEW_PROBLEM_HIDDEN); + if (!this.user.hasPriv(PRIV.PRIV_JUDGE)) { + this.checkPerm(PERM.PERM_VIEW_PROBLEM_HIDDEN); + } } await bus.serial('problem/get', this.pdoc, this); this.udoc = await user.getById(domainId, this.pdoc.owner); @@ -401,15 +403,17 @@ export class ProblemFilesHandler extends ProblemDetailHandler { @param('testdata', Types.Boolean) @param('additional_file', Types.Boolean) async get(domainId: string, getTestdata = true, getAdditionalFile = true) { - const canReadData = this.user._id === this.pdoc.owner || this.user.hasPerm(PERM.PERM_READ_PROBLEM_DATA); + const canReadData = this.user.hasPriv(PRIV.PRIV_JUDGE) + || this.user._id === this.pdoc.owner + || this.user.hasPerm(PERM.PERM_READ_PROBLEM_DATA); this.response.body.testdata = (getTestdata && canReadData) ? this.pdoc.data : []; this.response.body.additional_file = (getAdditionalFile ? this.pdoc.additional_file : []); this.response.template = 'problem_files.html'; } - @post('files', Types.Array) + @post('files', Types.Set) @post('type', Types.Range(['testdata', 'additional_file']), true) - async postGetLinks(domainId: string, files: string[], type = 'testdata') { + async postGetLinks(domainId: string, files: Set, type = 'testdata') { const isJudge = this.user.hasPriv(PRIV.PRIV_JUDGE); if (type === 'testdata' && !isJudge) { if (this.user._id !== this.pdoc.owner) { diff --git a/packages/hydrooj/src/service/server.ts b/packages/hydrooj/src/service/server.ts index 3c242e31e..a64b09d78 100644 --- a/packages/hydrooj/src/service/server.ts +++ b/packages/hydrooj/src/service/server.ts @@ -64,6 +64,7 @@ export interface Types { Time: Type, Range: (range: Array | Dictionary) => Type, Array: Type, + Set: Type, } export const Types: Types = { @@ -133,7 +134,11 @@ export const Types: Types = { ], Array: [(v) => { if (v instanceof Array) return v; - return [v] || []; + return v ? [v] : []; + }, null], + Set: [(v) => { + if (v instanceof Array) return new Set(v); + return v ? new Set([v]) : new Set(); }, null], };