mirror of
https://gitcode.com/gh_mirrors/hy/Hydro.git
synced 2026-10-18 09:36:08 +08:00
core&ui: add auto organize input option to hack (#780)
Co-authored-by: undefined <i@undefined.moe>
This commit is contained in:
1 parent
42569783f9
commit
ffe06804a7
7 files changed
+41
-5
No files matched your search
@@ -587,8 +587,9 @@ export class ProblemHackHandler extends ProblemDetailHandler {
|
||||
}
|
||||
|
||||
@param('input', Types.String, true)
|
||||
@param('autoOrganizeInput', Types.Boolean, true)
|
||||
@param('tid', Types.ObjectId, true)
|
||||
async post(domainId: string, input = '', tid?: ObjectId) {
|
||||
async post(domainId: string, input = '', autoOrganizeInput = false, tid?: ObjectId) {
|
||||
await this.limitRate('add_record', 60, system.get('limit.submission_user'), true);
|
||||
await this.limitRate('add_record', 60, system.get('limit.submission'), false);
|
||||
const id = `${this.user._id}/${nanoid()}`;
|
||||
@@ -597,12 +598,18 @@ export class ProblemHackHandler extends ProblemDetailHandler {
|
||||
if (!file || file.size > 128 * 1024 * 1024) throw new ValidationError('input');
|
||||
await storage.put(`submission/${id}`, file.filepath, this.user._id);
|
||||
} else if (input) {
|
||||
if (autoOrganizeInput) input = input.replace(/\s+\n/g, '\n').replace(/\s+ /g, ' ');
|
||||
await storage.put(`submission/${id}`, Buffer.from(input), this.user._id);
|
||||
}
|
||||
const rid = await record.add(
|
||||
domainId, this.pdoc.docId, this.user._id,
|
||||
this.rdoc.lang, this.rdoc.code, true,
|
||||
{ contest: tid, type: 'hack', files: { hack: `${id}#input.txt` } },
|
||||
{
|
||||
contest: tid,
|
||||
type: 'hack',
|
||||
hackTarget: this.rdoc._id,
|
||||
files: { hack: `${id}#input.txt` },
|
||||
},
|
||||
);
|
||||
// TODO contest: update status;
|
||||
this.response.body = { rid };
|
||||
|
||||
Reference in new issue
Block a user