mirror of
https://gitcode.com/gh_mirrors/hy/Hydro.git
synced 2026-10-19 17:38:19 +08:00
core: contest: add feature whitelist for hidden contest fule
This commit is contained in:
3 files changed
+15
No files matched your search
@@ -273,6 +273,11 @@ export class ContestPrintHandler extends ContestDetailBaseHandler {
|
||||
}
|
||||
|
||||
export class ContestProblemListHandler extends ContestDetailBaseHandler {
|
||||
@param('tid', Types.ObjectId)
|
||||
async prepare(domainId: string, tid: ObjectId) {
|
||||
if (contest.RULES[this.tdoc.rule].hidden) throw new ContestNotFoundError(domainId, tid);
|
||||
}
|
||||
|
||||
@param('tid', Types.ObjectId)
|
||||
async get(domainId: string, tid: ObjectId) {
|
||||
if (contest.isNotStarted(this.tdoc)) throw new ContestNotLiveError(domainId, tid);
|
||||
@@ -663,6 +668,9 @@ 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 (contest.RULES[this.tdoc.rule].hidden && !contest.RULES[this.tdoc.rule].features?.includes('download')) {
|
||||
throw new ContestNotFoundError(domainId, tid);
|
||||
}
|
||||
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);
|
||||
@@ -785,6 +793,9 @@ export class ContestScoreboardHandler extends ContestDetailBaseHandler {
|
||||
@param('tid', Types.ObjectId)
|
||||
@param('view', Types.String, true)
|
||||
async get(domainId: string, tid: ObjectId, viewId = 'default') {
|
||||
if (contest.RULES[this.tdoc.rule].hidden && !contest.RULES[this.tdoc.rule].features?.includes('scoreboard')) {
|
||||
throw new ContestNotFoundError(domainId, tid);
|
||||
}
|
||||
if (!this.user.own(this.tdoc)) {
|
||||
if (!contest.canShowScoreboard.call(this, this.tdoc, true)) throw new ContestScoreboardHiddenError(tid);
|
||||
if (contest.isNotStarted(this.tdoc)) throw new ContestNotLiveError(domainId, tid);
|
||||
|
||||
Reference in new issue
Block a user