fix: ships having wrong format in inventory response #2018
@ -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;
|
||||
|
@ -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;
|
||||
}
|
||||
});
|
||||
|
||||
|
@ -560,7 +560,7 @@ export interface ICrewShipCustomization {
|
||||
|
||||
export interface IShipExterior {
|
||||
SkinFlavourItem?: string;
|
||||
Colors: IColor;
|
||||
Colors?: IColor;
|
||||
ShipAttachments?: IShipAttachments;
|
||||
}
|
||||
|
||||
|
Loading…
x
Reference in New Issue
Block a user