feat: fervidex ch-omni enable

This commit is contained in:
zkldi
2022-11-02 03:33:15 +00:00
parent ed1fea4962
commit e921d2bb7b
3 changed files with 15 additions and 8 deletions
@@ -101,11 +101,12 @@ export function SoftwareIDToVersion(model: string, logger: KtLogger) {
} else if (data.ext === EXT_CASTHOUR) {
if (data.rev === REV_NORMAL) {
return "29";
} else if (data.rev === REV_2DXTRA) {
return "29-omni";
}
}
}
logger.warn(`Unsupported Software Model ${model}.`);
throw new ScoreImportFatalError(400, `Unsupported Software Model ${model}.`);
} catch (err) {
logger.warn(`Unsupported Software Model ${model}.`, { err });
@@ -10,6 +10,7 @@ import {
import { SYMBOL_TACHI_API_AUTH } from "lib/constants/tachi";
import CreateLogCtx from "lib/logger/logger";
import { ExpressWrappedScoreImportMain } from "lib/score-import/framework/express-wrapper";
import { SoftwareIDToVersion } from "lib/score-import/import-types/ir/fervidex/parser";
import p from "prudence";
import { RequirePermissions } from "server/middleware/auth";
import { PrudenceErrorFormatter } from "server/middleware/prudence-validate";
@@ -104,9 +105,12 @@ const ValidateModelHeader: RequestHandler = (req, res, next) => {
return;
}
if (softID.ext === undefined || !supportedExts.includes(softID.ext)) {
try {
SoftwareIDToVersion(swModel, logger);
} catch (err) {
logger.info(
`Rejected invalid Software Model ${softID.ext} from user ${req[SYMBOL_TACHI_API_AUTH].userID}.`
`Rejected invalid Software Model ${softID.ext} from user ${req[SYMBOL_TACHI_API_AUTH].userID}.`,
{ err }
);
return res.status(400).json({
success: false,
+7 -5
View File
@@ -5,18 +5,20 @@ export function ParseEA3SoftID(ver: string) {
throw new Error(`Invalid Version Code. Had ${a.length} components.`);
}
const arr = a as [string, string, string, string, string];
if (!/^[A-Z0-9]{3}:[A-Z]:[A-Z]:[A-Z]:[0-9]{10}$/u.exec(ver)) {
throw new Error(`Invalid Version Code.`);
}
return {
model: a[0],
model: arr[0],
// region
dest: a[1],
dest: arr[1],
spec: a[2],
rev: a[3],
ext: a[4],
spec: arr[2],
rev: arr[3],
ext: arr[4],
};
}