diff --git a/packages/hydrooj/locales/en.yaml b/packages/hydrooj/locales/en.yaml index 7b5d4bde8..45ec86366 100644 --- a/packages/hydrooj/locales/en.yaml +++ b/packages/hydrooj/locales/en.yaml @@ -60,7 +60,6 @@ problem_detail: Problem Detail problem_edit: Problem Edit problem_import: Import Problem problem_main: Problem Set -problem_settings: Problem Settings problem_solution: Problem Solution problem_statistics: Problem Statistics problem_submit: Problem Submit diff --git a/packages/hydrooj/locales/ko.yaml b/packages/hydrooj/locales/ko.yaml index 2c6c55ec4..386adccde 100644 --- a/packages/hydrooj/locales/ko.yaml +++ b/packages/hydrooj/locales/ko.yaml @@ -525,7 +525,6 @@ problem_create: 문제 만들기 problem_edit: 문제 수정 problem_import: 문제 가져오기 problem_main: 문제 -problem_settings: 문제 설정 problem_solution: 문제 해설 problem_statistics: 문제 통계 problem_submit: 제출 diff --git a/packages/hydrooj/locales/zh.yaml b/packages/hydrooj/locales/zh.yaml index cad1fc3b6..7ca97a393 100644 --- a/packages/hydrooj/locales/zh.yaml +++ b/packages/hydrooj/locales/zh.yaml @@ -540,7 +540,6 @@ problem_files: 题目文件 problem_import_syzoj: 从 SYZOJ 导入题目 problem_import: 导入题目 problem_main: 题库 -problem_settings: 题目设置 problem_solution: 题解 problem_statistics: 题目统计 problem_submit: 递交代码 diff --git a/packages/hydrooj/locales/zh_TW.yaml b/packages/hydrooj/locales/zh_TW.yaml index 0dce065fb..2392851c0 100644 --- a/packages/hydrooj/locales/zh_TW.yaml +++ b/packages/hydrooj/locales/zh_TW.yaml @@ -344,7 +344,6 @@ Problem Tags Visibility: 題目標籤可見性 problem_create: 創建題目 problem_edit: 編輯題目 problem_main: 題庫 -problem_settings: 題目設定 problem_solution: 題解 problem_submit: 遞交程式碼 Problem: 題目 diff --git a/packages/hydrooj/package.json b/packages/hydrooj/package.json index 91b74b104..f051c38d4 100644 --- a/packages/hydrooj/package.json +++ b/packages/hydrooj/package.json @@ -1,6 +1,6 @@ { "name": "hydrooj", - "version": "2.20.7", + "version": "2.20.8", "bin": "bin/hydrooj.js", "main": "dist/loader.js", "typings": "dist/loader.d.ts", diff --git a/packages/hydrooj/src/handler/import.syzoj.ts b/packages/hydrooj/src/handler/import.syzoj.ts index c953d9d74..065de5aff 100644 --- a/packages/hydrooj/src/handler/import.syzoj.ts +++ b/packages/hydrooj/src/handler/import.syzoj.ts @@ -246,11 +246,11 @@ class ProblemImportSYZOJHandler extends Handler { protocol, host, pid, false, ); this.response.body = { pid: targetPid || docId }; - this.response.redirect = this.url('problem_settings', { pid: targetPid || docId }); + this.response.redirect = this.url('problem_files', { pid: targetPid || docId }); } else { const docId = await this.v2(domainId, targetPid, hidden, url); this.response.body = { pid: targetPid || docId }; - this.response.redirect = this.url('problem_settings', { pid: targetPid || docId }); + this.response.redirect = this.url('problem_files', { pid: targetPid || docId }); } } } diff --git a/packages/hydrooj/src/handler/problem.ts b/packages/hydrooj/src/handler/problem.ts index 0798af2f3..b2f0b4561 100644 --- a/packages/hydrooj/src/handler/problem.ts +++ b/packages/hydrooj/src/handler/problem.ts @@ -552,17 +552,17 @@ export class ProblemCreateHandler extends Handler { @post('title', Types.String, isTitle) @post('content', Types.String, isContent) - @post('pid', Types.String, isPid, true) + @post('pid', Types.String, true, isPid) @post('hidden', Types.Boolean) @post('tag', Types.String, true, null, parseCategory) async post(domainId: string, title: string, content: string, pid: string, hidden = false, tag: string[] = []) { try { content = JSON.parse(content); } catch { /* Ignore */ } - if (await problem.get(domainId, pid)) throw new BadRequestError('invalid pid'); + if (pid && await problem.get(domainId, pid)) throw new BadRequestError('invalid pid'); const docId = await problem.add(domainId, pid, title, content, this.user._id, tag, hidden); this.response.body = { pid: pid || docId }; - this.response.redirect = this.url('problem_settings', { pid: pid || docId }); + this.response.redirect = this.url('problem_files', { pid: pid || docId }); } } diff --git a/packages/hydrooj/src/model/token.ts b/packages/hydrooj/src/model/token.ts index 9d5dfc04a..8adcebca1 100644 --- a/packages/hydrooj/src/model/token.ts +++ b/packages/hydrooj/src/model/token.ts @@ -21,19 +21,18 @@ function ensureIndexes() { } export async function add( - tokenType: number, expireSeconds: number, data: any, + tokenType: number, expireSeconds: number, data: any, id = String.random(32), ): Promise<[string, TokenDoc]> { const now = new Date(); - const str = String.random(32); const res = await coll.insertOne({ ...data, - _id: str, + _id: id, tokenType, createAt: now, updateAt: now, expireAt: new Date(now.getTime() + expireSeconds * 1000), }); - return [str, res.ops[0]]; + return [id, res.ops[0]]; } export async function get(tokenId: string, tokenType: number): Promise {