mirror of
https://gitcode.com/gh_mirrors/hy/Hydro.git
synced 2026-10-20 01:38:19 +08:00
core: 支持限制题目的提交语言
This commit is contained in:
1 parent
f33d440b68
commit
75429bb43b
10 files changed
+44
-25
No files matched your search
@@ -4,7 +4,7 @@ import AdmZip from 'adm-zip';
|
||||
import { isSafeInteger } from 'lodash';
|
||||
import {
|
||||
ContestNotLiveError, ValidationError, ProblemNotFoundError,
|
||||
ContestNotAttendedError, PermissionError,
|
||||
ContestNotAttendedError, PermissionError, BadRequestError,
|
||||
} from '../error';
|
||||
import { ProblemDoc, Tdoc, User } from '../interface';
|
||||
import paginate from '../lib/paginate';
|
||||
@@ -344,6 +344,9 @@ class ContestDetailProblemSubmitHandler extends ContestProblemHandler {
|
||||
@param('lang', Types.Name)
|
||||
@param('code', Types.Content)
|
||||
async post(domainId: string, tid: ObjectID, lang: string, code: string) {
|
||||
if (this.response.body.pdoc.config.langs && !this.response.body.pdoc.config.langs.includes('lang')) {
|
||||
throw new BadRequestError('Language not allowed.');
|
||||
}
|
||||
await this.limitRate('add_record', 60, 10);
|
||||
const rid = await record.add(domainId, this.pdoc.docId, this.user._id, lang, code, true, {
|
||||
type: document.TYPE_CONTEST,
|
||||
|
||||
@@ -264,6 +264,9 @@ export class ProblemSubmitHandler extends ProblemDetailHandler {
|
||||
@param('lang', Types.Name)
|
||||
@param('code', Types.Content)
|
||||
async post(domainId: string, lang: string, code: string) {
|
||||
if (this.response.body.pdoc.config.langs && !this.response.body.pdoc.config.langs.includes('lang')) {
|
||||
throw new BadRequestError('Language not allowed.');
|
||||
}
|
||||
await this.limitRate('add_record', 60, 5);
|
||||
const rid = await record.add(domainId, this.pdoc.docId, this.user._id, lang, code, true);
|
||||
const [rdoc] = await Promise.all([
|
||||
|
||||
Reference in new issue
Block a user