fix: ships having wrong format in inventory response
All checks were successful
Build / build (push) Successful in 1m43s
Build / build (pull_request) Successful in 53s

This commit is contained in:
Sainan 2025-05-08 12:49:58 +02:00
parent 42c63ecbe8
commit 2f11fb4f0c
3 changed files with 16 additions and 18 deletions

View File

@ -28,6 +28,7 @@ import { isNemesisCompatibleWithVersion } from "@/src/helpers/nemesisHelpers";
import { version_compare } from "@/src/services/worldStateService";
import { getPersonalRooms } from "@/src/services/personalRoomsService";
import { IPersonalRoomsClient } from "@/src/types/personalRoomsTypes";
import { Ship } from "@/src/models/shipModel";
export const inventoryController: RequestHandler = async (request, response) => {
const account = await getAccountForRequest(request);
@ -133,13 +134,12 @@ export const getInventoryResponse = async (
xpBasedLevelCapDisabled: boolean,
buildLabel: string | undefined
): Promise<IInventoryClient> => {
const inventoryWithLoadOutPresets = await inventory.populate<{ LoadOutPresets: ILoadoutDatabase }>(
"LoadOutPresets"
);
const inventoryWithLoadOutPresetsAndShips = await inventoryWithLoadOutPresets.populate<{ Ships: IShipInventory }>(
"Ships"
);
const inventoryResponse = inventoryWithLoadOutPresetsAndShips.toJSON<IInventoryClient>();
const [inventoryWithLoadOutPresets, ships] = await Promise.all([
inventory.populate<{ LoadOutPresets: ILoadoutDatabase }>("LoadOutPresets"),
Ship.find({ ShipOwnerId: inventory.accountOwnerId })
]);
const inventoryResponse = inventoryWithLoadOutPresets.toJSON<IInventoryClient>();
inventoryResponse.Ships = ships.map(x => x.toJSON<IShipInventory>());
if (config.infiniteCredits) {
inventoryResponse.RegularCredits = 999999999;

View File

@ -28,17 +28,15 @@ shipSchema.set("toJSON", {
delete returnedObject._id;
delete returnedObject.__v;
delete returnedObject.ShipOwnerId;
if (shipDatabase.ShipExteriorColors) {
shipResponse.ShipExterior = {
Colors: shipDatabase.ShipExteriorColors,
ShipAttachments: shipDatabase.ShipAttachments,
SkinFlavourItem: shipDatabase.SkinFlavourItem
};
delete shipDatabase.ShipExteriorColors;
delete shipDatabase.ShipAttachments;
delete shipDatabase.SkinFlavourItem;
}
shipResponse.ShipExterior = {
Colors: shipDatabase.ShipExteriorColors,
ShipAttachments: shipDatabase.ShipAttachments,
SkinFlavourItem: shipDatabase.SkinFlavourItem
};
delete shipDatabase.ShipExteriorColors;
delete shipDatabase.ShipAttachments;
delete shipDatabase.SkinFlavourItem;
}
});

View File

@ -560,7 +560,7 @@ export interface ICrewShipCustomization {
export interface IShipExterior {
SkinFlavourItem?: string;
Colors: IColor;
Colors?: IColor;
ShipAttachments?: IShipAttachments;
}