mirror of
https://github.com/zkldi/Tachi.git
synced 2026-10-06 05:48:00 +03:00
Change ir/beatorajas client check to a graylist rather than a whitelist
Fixes #632
This commit is contained in:
@@ -126,18 +126,17 @@ export function ParseBeatorajaSingle(
|
||||
const score = body.score as BeatorajaScore;
|
||||
const chart = body.chart as BeatorajaChart;
|
||||
|
||||
if (chart.mode === "BEAT_14K" || chart.mode === "BEAT_7K") {
|
||||
if (!SUPPORTED_BMS_CLIENTS.includes(client)) {
|
||||
throw new ScoreImportFatalError(400, `Unsupported BMS client ${client}`);
|
||||
}
|
||||
} else if (chart.mode === "POPN_9K") {
|
||||
if (!SUPPORTED_PMS_CLIENTS.includes(client)) {
|
||||
throw new ScoreImportFatalError(400, `Unsupported PMS client ${client}`);
|
||||
}
|
||||
}
|
||||
|
||||
const isPMS = chart.mode === "POPN_9K";
|
||||
|
||||
const expectedClient = isPMS ? "beatoraja" : "LR2oraja";
|
||||
|
||||
if (!client.startsWith(expectedClient)) {
|
||||
throw new ScoreImportFatalError(
|
||||
400,
|
||||
`Unsupported client ${client} -- Expected a variant of ${expectedClient}.`
|
||||
);
|
||||
}
|
||||
|
||||
return {
|
||||
context: {
|
||||
client: isPMS ? "beatoraja" : "lr2oraja",
|
||||
|
||||
@@ -150,7 +150,7 @@ t.test("POST /ir/beatoraja/submit-score", (t) => {
|
||||
t.equal(res.status, 400);
|
||||
|
||||
t.equal(res.body.success, false);
|
||||
t.match(res.body.description, /Unsupported BMS client/u);
|
||||
t.match(res.body.description, /Unsupported client/u);
|
||||
|
||||
t.end();
|
||||
});
|
||||
@@ -165,7 +165,7 @@ t.test("POST /ir/beatoraja/submit-score", (t) => {
|
||||
t.equal(res.status, 400);
|
||||
|
||||
t.equal(res.body.success, false);
|
||||
t.match(res.body.description, /Unsupported BMS client/u);
|
||||
t.match(res.body.description, /Unsupported client/u);
|
||||
|
||||
t.end();
|
||||
});
|
||||
@@ -180,7 +180,7 @@ t.test("POST /ir/beatoraja/submit-score", (t) => {
|
||||
t.equal(res.status, 400);
|
||||
|
||||
t.equal(res.body.success, false);
|
||||
t.match(res.body.description, /Unsupported PMS client/u);
|
||||
t.match(res.body.description, /Unsupported client/u);
|
||||
|
||||
t.end();
|
||||
});
|
||||
|
||||
Reference in New Issue
Block a user