fix(import): handle ship features being in inventory
All checks were successful
Build / build (pull_request) Successful in 56s
All checks were successful
Build / build (pull_request) Successful in 56s
This commit is contained in:
parent
dfd1fb834b
commit
cbe7768670
@ -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();
|
||||||
|
|||||||
@ -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);
|
||||||
};
|
};
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user