fix(import): handle ship features being in inventory (#2688)
Some checks failed
Build Docker image / docker-amd64 (push) Waiting to run
Build / build (push) Has been cancelled
Build Docker image / docker-arm64 (push) Has been cancelled

Closes #2686

Reviewed-on: #2688
Co-authored-by: Sainan <63328889+Sainan@users.noreply.github.com>
Co-committed-by: Sainan <63328889+Sainan@users.noreply.github.com>
This commit is contained in:
Sainan 2025-08-24 15:15:50 -07:00 committed by Sainan
parent dfd1fb834b
commit ffcbbb480b
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();
}
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);
importPersonalRooms(personalRooms, request.inventory);
await personalRooms.save();

View File

@ -570,7 +570,7 @@ const convertTailorShop = (client: ITailorShop): ITailorShopDatabase => {
};
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.TailorShop !== undefined) db.TailorShop = convertTailorShop(client.TailorShop);
};