mirror of
https://gitcode.com/gh_mirrors/hy/Hydro.git
synced 2026-10-20 01:38:19 +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",
|
"name": "hydrooj",
|
||||||
"version": "2.20.15",
|
"version": "2.20.16",
|
||||||
"bin": "bin/hydrooj.js",
|
"bin": "bin/hydrooj.js",
|
||||||
"main": "dist/loader.js",
|
"main": "dist/loader.js",
|
||||||
"typings": "dist/loader.d.ts",
|
"typings": "dist/loader.d.ts",
|
||||||
|
|||||||
@@ -323,14 +323,14 @@ export class ProblemEditHandler extends ProblemManageHandler {
|
|||||||
@post('tag', Types.String, true, null, parseCategory)
|
@post('tag', Types.String, true, null, parseCategory)
|
||||||
async post(
|
async post(
|
||||||
domainId: string, pid: string | number, title: string, content: string,
|
domainId: string, pid: string | number, title: string, content: string,
|
||||||
newPid: string = '', hidden = false, tag: string[],
|
newPid: string = '', hidden = false, tag: string[] = [],
|
||||||
) {
|
) {
|
||||||
try {
|
try {
|
||||||
content = JSON.parse(content);
|
content = JSON.parse(content);
|
||||||
} catch { /* Ignore */ }
|
} catch { /* Ignore */ }
|
||||||
if (newPid !== this.pdoc.pid && await problem.get(domainId, newPid)) throw new BadRequestError('new pid exists');
|
if (newPid !== this.pdoc.pid && await problem.get(domainId, newPid)) throw new BadRequestError('new pid exists');
|
||||||
const $update: Partial<Pdoc> = {
|
const $update: Partial<Pdoc> = {
|
||||||
title, content, pid: newPid, hidden, tag,
|
title, content, pid: newPid, hidden, tag: tag ?? [],
|
||||||
};
|
};
|
||||||
let pdoc = await problem.get(domainId, pid);
|
let pdoc = await problem.get(domainId, pid);
|
||||||
await bus.serial('problem/before-edit', $update);
|
await bus.serial('problem/before-edit', $update);
|
||||||
@@ -560,7 +560,7 @@ export class ProblemCreateHandler extends Handler {
|
|||||||
content = JSON.parse(content);
|
content = JSON.parse(content);
|
||||||
} catch { /* Ignore */ }
|
} catch { /* Ignore */ }
|
||||||
if (pid && 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);
|
const docId = await problem.add(domainId, pid, title, content, this.user._id, tag ?? [], hidden);
|
||||||
this.response.body = { pid: pid || docId };
|
this.response.body = { pid: pid || docId };
|
||||||
this.response.redirect = this.url('problem_files', { pid: pid || docId });
|
this.response.redirect = this.url('problem_files', { pid: pid || docId });
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -200,6 +200,12 @@ const scripts: UpgradeScript[] = [
|
|||||||
});
|
});
|
||||||
return true;
|
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;
|
export = scripts;
|
||||||
Reference in new issue
Block a user