mirror of
https://gitcode.com/gh_mirrors/hy/Hydro.git
synced 2026-10-19 17:38:19 +08:00
core: disallow to rejudge pretest record (#796)
This commit is contained in:
1 parent
5186e35712
commit
89448d5678
2 files changed
+5
-4
No files matched your search
@@ -114,6 +114,7 @@ export const ProblemAlreadyUsedByContestError = Err('ProblemAlreadyUsedByContest
|
|||||||
export const ProblemNotAllowPretestError = Err('ProblemNotAllowPretestError', ForbiddenError, 'Pretesting is not supported for {0}.');
|
export const ProblemNotAllowPretestError = Err('ProblemNotAllowPretestError', ForbiddenError, 'Pretesting is not supported for {0}.');
|
||||||
export const ProblemNotAllowLanguageError = Err('ProblemNotAllowSubmitError', ForbiddenError, 'This language is not allowed to submit.');
|
export const ProblemNotAllowLanguageError = Err('ProblemNotAllowSubmitError', ForbiddenError, 'This language is not allowed to submit.');
|
||||||
|
|
||||||
|
export const PretestRejudgeFailedError = Err('PretestRejudgeFailedError', BadRequestError, 'Cannot rejudge a pretest record.');
|
||||||
export const HackRejudgeFailedError = Err('HackRejudgeFailedError', BadRequestError, 'Cannot rejudge a hack record.');
|
export const HackRejudgeFailedError = Err('HackRejudgeFailedError', BadRequestError, 'Cannot rejudge a hack record.');
|
||||||
export const CannotDeleteSystemDomainError = Err('CannotDeleteSystemDomainError', BadRequestError, 'You are not allowed to delete system domain.');
|
export const CannotDeleteSystemDomainError = Err('CannotDeleteSystemDomainError', BadRequestError, 'You are not allowed to delete system domain.');
|
||||||
export const OnlyOwnerCanDeleteDomainError = Err('OnlyOwnerCanDeleteDomainError', BadRequestError, 'You are not the owner of this domain.');
|
export const OnlyOwnerCanDeleteDomainError = Err('OnlyOwnerCanDeleteDomainError', BadRequestError, 'You are not the owner of this domain.');
|
||||||
|
|||||||
@@ -4,7 +4,7 @@ import {
|
|||||||
import { Filter, ObjectId } from 'mongodb';
|
import { Filter, ObjectId } from 'mongodb';
|
||||||
import {
|
import {
|
||||||
ContestNotFoundError, HackRejudgeFailedError,
|
ContestNotFoundError, HackRejudgeFailedError,
|
||||||
PermissionError, ProblemConfigError,
|
PermissionError, PretestRejudgeFailedError, ProblemConfigError,
|
||||||
ProblemNotFoundError, RecordNotFoundError, UserNotFoundError,
|
ProblemNotFoundError, RecordNotFoundError, UserNotFoundError,
|
||||||
} from '../error';
|
} from '../error';
|
||||||
import { RecordDoc, Tdoc } from '../interface';
|
import { RecordDoc, Tdoc } from '../interface';
|
||||||
@@ -177,7 +177,7 @@ class RecordDetailHandler extends ContestDetailBaseHandler {
|
|||||||
|
|
||||||
// eslint-disable-next-line prefer-const
|
// eslint-disable-next-line prefer-const
|
||||||
let [pdoc, self, udoc] = await Promise.all([
|
let [pdoc, self, udoc] = await Promise.all([
|
||||||
problem.get(rdoc.domainId, rdoc.pid),
|
problem.get(rdoc.domainId, rdoc.pid, problem.PROJECTION_LIST),
|
||||||
problem.getStatus(domainId, rdoc.pid, this.user._id),
|
problem.getStatus(domainId, rdoc.pid, this.user._id),
|
||||||
user.getById(domainId, rdoc.uid),
|
user.getById(domainId, rdoc.uid),
|
||||||
]);
|
]);
|
||||||
@@ -209,6 +209,7 @@ class RecordDetailHandler extends ContestDetailBaseHandler {
|
|||||||
async post() {
|
async post() {
|
||||||
this.checkPerm(PERM.PERM_REJUDGE);
|
this.checkPerm(PERM.PERM_REJUDGE);
|
||||||
if (this.rdoc.files?.hack) throw new HackRejudgeFailedError();
|
if (this.rdoc.files?.hack) throw new HackRejudgeFailedError();
|
||||||
|
if (this.rdoc.contest?.toString().startsWith('0'.repeat(23))) throw new PretestRejudgeFailedError();
|
||||||
}
|
}
|
||||||
|
|
||||||
@param('rid', Types.ObjectId)
|
@param('rid', Types.ObjectId)
|
||||||
@@ -216,10 +217,9 @@ class RecordDetailHandler extends ContestDetailBaseHandler {
|
|||||||
const pdoc = await problem.get(domainId, this.rdoc.pid);
|
const pdoc = await problem.get(domainId, this.rdoc.pid);
|
||||||
if (!pdoc?.config || typeof pdoc.config === 'string') throw new ProblemConfigError();
|
if (!pdoc?.config || typeof pdoc.config === 'string') throw new ProblemConfigError();
|
||||||
const priority = await record.submissionPriority(this.user._id, -20);
|
const priority = await record.submissionPriority(this.user._id, -20);
|
||||||
const isContest = this.rdoc.contest && this.rdoc.contest.toString() !== '000000000000000000000000';
|
|
||||||
const rdoc = await record.reset(domainId, rid, true);
|
const rdoc = await record.reset(domainId, rid, true);
|
||||||
this.ctx.broadcast('record/change', rdoc);
|
this.ctx.broadcast('record/change', rdoc);
|
||||||
await record.judge(domainId, rid, priority, isContest ? { detail: false } : {});
|
await record.judge(domainId, rid, priority, this.rdoc.contest ? { detail: false } : {});
|
||||||
this.back();
|
this.back();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
Reference in new issue
Block a user