fix(import): handle ship features being in inventory (#2688)
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:
parent
dfd1fb834b
commit
ffcbbb480b
@ -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();
|
||||
|
||||
@ -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);
|
||||
};
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user