mirror of
https://github.com/openfrontio/OpenFrontIO.git
synced 2026-07-02 08:28:12 +00:00
Fix archive (#2035)
## Description: Describe the PR. ## Please complete the following: - [x] I have added screenshots for all UI updates - [x] I process any text displayed to the user through translateText() and I've added it to the en.json file - [x] I have added relevant tests to the test directory - [x] I confirm I have thoroughly tested these changes and take full responsibility for any bugs introduced ## Please put your Discord username so you can be contacted if a bug or regression is found: evan
This commit is contained in:
@@ -12,13 +12,12 @@ import { getServerConfigFromServer } from "../core/configuration/ConfigLoader";
|
||||
import { GameType } from "../core/game/Game";
|
||||
import {
|
||||
ClientMessageSchema,
|
||||
GameRecord,
|
||||
GameRecordSchema,
|
||||
ID,
|
||||
PartialGameRecordSchema,
|
||||
ServerErrorMessage,
|
||||
} from "../core/Schemas";
|
||||
import { CreateGameInputSchema, GameInputSchema } from "../core/WorkerSchemas";
|
||||
import { archive, readGameRecord } from "./Archive";
|
||||
import { archive, finalizeGameRecord, readGameRecord } from "./Archive";
|
||||
import { Client } from "./Client";
|
||||
import { GameManager } from "./GameManager";
|
||||
import { getUserMe, verifyClientToken } from "./jwt";
|
||||
@@ -252,13 +251,13 @@ export async function startWorker() {
|
||||
try {
|
||||
const record = req.body;
|
||||
|
||||
const result = GameRecordSchema.safeParse(record);
|
||||
const result = PartialGameRecordSchema.safeParse(record);
|
||||
if (!result.success) {
|
||||
const error = z.prettifyError(result.error);
|
||||
log.info(error);
|
||||
return res.status(400).json({ error });
|
||||
}
|
||||
const gameRecord: GameRecord = result.data;
|
||||
const gameRecord = result.data;
|
||||
|
||||
if (gameRecord.info.config.gameType !== GameType.Singleplayer) {
|
||||
log.warn(
|
||||
@@ -277,7 +276,11 @@ export async function startWorker() {
|
||||
return res.status(400).json({ error: "Invalid request" });
|
||||
}
|
||||
|
||||
archive(gameRecord);
|
||||
log.info("archiving singleplayer game", {
|
||||
gameID: gameRecord.info.gameID,
|
||||
});
|
||||
|
||||
archive(finalizeGameRecord(gameRecord));
|
||||
res.json({
|
||||
success: true,
|
||||
});
|
||||
|
||||
Reference in New Issue
Block a user