mirror of
https://gitcode.com/gh_mirrors/hy/Hydro.git
synced 2026-10-17 09:36:08 +08:00
core: fix problem_edit returns null
This commit is contained in:
1 parent
b240a46057
commit
391eb96b22
3 files changed
+10
-4
No files matched your search
@@ -1,6 +1,6 @@
|
||||
{
|
||||
"name": "hydrooj",
|
||||
"version": "2.20.15",
|
||||
"version": "2.20.16",
|
||||
"bin": "bin/hydrooj.js",
|
||||
"main": "dist/loader.js",
|
||||
"typings": "dist/loader.d.ts",
|
||||
|
||||
@@ -323,14 +323,14 @@ export class ProblemEditHandler extends ProblemManageHandler {
|
||||
@post('tag', Types.String, true, null, parseCategory)
|
||||
async post(
|
||||
domainId: string, pid: string | number, title: string, content: string,
|
||||
newPid: string = '', hidden = false, tag: string[],
|
||||
newPid: string = '', hidden = false, tag: string[] = [],
|
||||
) {
|
||||
try {
|
||||
content = JSON.parse(content);
|
||||
} catch { /* Ignore */ }
|
||||
if (newPid !== this.pdoc.pid && await problem.get(domainId, newPid)) throw new BadRequestError('new pid exists');
|
||||
const $update: Partial<Pdoc> = {
|
||||
title, content, pid: newPid, hidden, tag,
|
||||
title, content, pid: newPid, hidden, tag: tag ?? [],
|
||||
};
|
||||
let pdoc = await problem.get(domainId, pid);
|
||||
await bus.serial('problem/before-edit', $update);
|
||||
@@ -560,7 +560,7 @@ export class ProblemCreateHandler extends Handler {
|
||||
content = JSON.parse(content);
|
||||
} catch { /* Ignore */ }
|
||||
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);
|
||||
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_files', { pid: pid || docId });
|
||||
}
|
||||
|
||||
@@ -200,6 +200,12 @@ const scripts: UpgradeScript[] = [
|
||||
});
|
||||
return true;
|
||||
},
|
||||
// Set null tag to []
|
||||
async function _9_10() {
|
||||
const _FRESH_INSTALL_IGNORE = 1;
|
||||
await db.collection('document').updateMany({ docType: 10, tag: null }, { $set: { tag: [] } });
|
||||
return true;
|
||||
},
|
||||
];
|
||||
|
||||
export = scripts;
|
||||
Reference in new issue
Block a user