fix(import): handle ship features being in inventory
All checks were successful
Build / build (pull_request) Successful in 56s

This commit is contained in:
Sainan 2025-08-24 00:09:03 +02:00
parent dfd1fb834b
commit cbe7768670
2 changed files with 6 additions and 2 deletions

View File

@ -21,7 +21,11 @@ export const importController: RequestHandler = async (req, res) => {
await loadout.save(); await loadout.save();
} }
if ("Ship" in request.inventory || "Apartment" in request.inventory || "TailorShop" in request.inventory) { if (
request.inventory.Ship?.Rooms || // very old accounts may have Ship with { Features: [ ... ] }
"Apartment" in request.inventory ||
"TailorShop" in request.inventory
) {
const personalRooms = await getPersonalRooms(accountId); const personalRooms = await getPersonalRooms(accountId);
importPersonalRooms(personalRooms, request.inventory); importPersonalRooms(personalRooms, request.inventory);
await personalRooms.save(); await personalRooms.save();

View File

@ -570,7 +570,7 @@ const convertTailorShop = (client: ITailorShop): ITailorShopDatabase => {
}; };
export const importPersonalRooms = (db: IPersonalRoomsDatabase, client: Partial<IGetShipResponse>): void => { export const importPersonalRooms = (db: IPersonalRoomsDatabase, client: Partial<IGetShipResponse>): void => {
if (client.Ship !== undefined) db.Ship = convertShip(client.Ship); if (client.Ship?.Rooms) db.Ship = convertShip(client.Ship);
if (client.Apartment !== undefined) db.Apartment = convertApartment(client.Apartment); if (client.Apartment !== undefined) db.Apartment = convertApartment(client.Apartment);
if (client.TailorShop !== undefined) db.TailorShop = convertTailorShop(client.TailorShop); if (client.TailorShop !== undefined) db.TailorShop = convertTailorShop(client.TailorShop);
}; };