core: remote judge api

This commit is contained in:
undefined committed 2021-06-21 13:39:39 +08:00
1 parent 939584ec5e
commit 680e3ccd32
11 files changed
+54 -13

No files matched your search

+5 -1
View File
@@ -212,7 +212,8 @@ export class ProblemDetailHandler extends ProblemHandler {
// e.g. ![img](a.jpg) will navigate to ![img](./pid/file/a.jpg)
if (!this.request.json) {
this.response.body.pdoc.content = this.response.body.pdoc.content
.replace(/\(file:\/\//g, `(./${this.pdoc.docId}/file/`);
.replace(/\(file:\/\//g, `(./${this.pdoc.docId}/file/`)
.replace(/="file:\/\//g, `="./${this.pdoc.docId}/file/`);
}
if (this.psdoc) {
this.response.body.rdoc = await record.get(this.domainId, this.psdoc.rid);
@@ -269,6 +270,9 @@ export class ProblemSubmitHandler extends ProblemDetailHandler {
if (this.response.body.pdoc.config?.langs && !this.response.body.pdoc.config.langs.includes(lang)) {
throw new BadRequestError('Language not allowed.');
}
if (this.domain.langs && !this.domain.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, pretest ? input : undefined);
const rdoc = await record.get(domainId, rid);