core: problem.get with raw config

This commit is contained in:
undefined committed 2021-11-22 23:18:27 +08:00
1 parent 973f19db68
commit f768e96867
2 files changed
+3 -2

No files matched your search

+1 -1
View File
@@ -1,6 +1,6 @@
{
"name": "hydrooj",
"version": "3.1.32",
"version": "3.1.33",
"bin": "bin/hydrooj.js",
"main": "src/loader",
"module": "src/loader",
+2 -1
View File
@@ -107,6 +107,7 @@ export class ProblemModel {
static async get(
domainId: string, pid: string | number,
projection: Projection<ProblemDoc> = ProblemModel.PROJECTION_PUBLIC,
rawConfig = false,
): Promise<ProblemDoc | null> {
if (typeof pid !== 'number') {
if (Number.isSafeInteger(parseInt(pid, 10))) pid = parseInt(pid, 10);
@@ -116,7 +117,7 @@ export class ProblemModel {
: (await document.getMulti(domainId, document.TYPE_PROBLEM, { pid }).toArray())[0];
if (!res) return null;
try {
res.config = await parseConfig(res.config);
if (!rawConfig) res.config = await parseConfig(res.config);
} catch (e) {
res.config = `Cannot parse: ${e.message}`;
}