移除可以与同一用户创建多个会话的特性

This commit is contained in:
masnn committed 2020-05-15 13:10:41 +08:00
1 parent d04628148f
commit 3c5fdb9032
16 files changed
+120 -118

No files matched your search

@@ -4,7 +4,7 @@ const { download } = global.Hydro.lib;
const { axios } = global.Hydro.lib;
const { ValidationError, RemoteOnlineJudgeError } = global.Hydro.error;
async function syzoj(url) {
async function syzoj(url, handler) {
const RE_SYZOJ = /https?:\/\/([a-zA-Z0-9.]+)\/problem\/([0-9]+)\/?/i;
assert(url.match(RE_SYZOJ), new ValidationError('url'));
if (!url.endsWith('/')) url += '/';
@@ -13,40 +13,59 @@ async function syzoj(url) {
assert(res.status === 200, new RemoteOnlineJudgeError('Cannot connect to target server'));
assert(res.data.success, new RemoteOnlineJudgeError((res.data.error || {}).message));
const p = res.data.obj;
const content = [
this.translate('problem.import.problem_description'),
p.description,
this.translate('problem.import.input_format'),
p.input_format,
this.translate('problem.import.output_format'),
p.output_format,
this.translate('problem.import.hint'),
p.hint,
this.translate('problem.import.limit_and_hint'),
p.limit_and_hint,
];
const content = [];
if (p.description) {
content.push(
handler.translate('problem.import.problem_description'),
p.description,
);
}
if (p.input_format) {
content.push(
handler.translate('problem.import.input_format'),
p.input_format,
);
}
if (p.output_format) {
content.push(
handler.translate('problem.import.output_format'),
p.output_format,
);
}
if (p.hint) {
content.push(
handler.translate('problem.import.hint'),
p.hint,
);
}
if (p.limit_and_hint) {
content.push(
handler.translate('problem.import.limit_and_hint'),
p.limit_and_hint,
);
}
if (p.have_additional_file) {
content.push(
this.translate('problem.import.additional_file'),
handler.translate('problem.import.additional_file'),
`${url}download/additional_file`,
);
}
const pdoc = {
title: p.title,
content: content.join(' \n'),
owner: this.user._id,
owner: handler.user._id,
from: url,
pid: `${host}_${pid}`,
tags: p.tags,
config: {
time: p.time_limit,
memory: p.memory_limit * 1024,
filename: p.file_io_input_name,
type: p.type,
tags: p.tags,
},
};
const r = await download(`${url}testdata/download`);
return [pdoc, r];
}
global.Hydro.handler.import.ProblemImportHandler.from_syzoj = syzoj;
global.Hydro.lib['import.syzoj'] = syzoj;
@@ -1 +1,8 @@
Import problem from syzoj.: 从运行 syzoj 系统的 OJ 导入题目。
Import problem from syzoj.: 从运行 syzoj 系统的 OJ 导入题目。
problem.import.problem_description: '## 题目描述'
problem.import.input_format: '## 输入格式'
problem.import.output_format: '## 输出格式'
problem.import.hint: '## 提示'
problem.import.limit_and_hint: '## 限制'
problem.import.additional_file: '## 附加文件'
import: 导入