fix: ships having wrong format in inventory response (#2018)
All checks were successful
Build Docker image / docker (push) Successful in 36s
Build / build (push) Successful in 1m40s

Reviewed-on: #2018
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-05-08 04:51:03 -07:00 committed by Sainan
parent d831732513
commit b987e01811
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;
}