fix: ships having wrong format in inventory response (#2018)
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:
parent
d831732513
commit
b987e01811
@ -28,6 +28,7 @@ import { isNemesisCompatibleWithVersion } from "@/src/helpers/nemesisHelpers";
|
|||||||
import { version_compare } from "@/src/services/worldStateService";
|
import { version_compare } from "@/src/services/worldStateService";
|
||||||
import { getPersonalRooms } from "@/src/services/personalRoomsService";
|
import { getPersonalRooms } from "@/src/services/personalRoomsService";
|
||||||
import { IPersonalRoomsClient } from "@/src/types/personalRoomsTypes";
|
import { IPersonalRoomsClient } from "@/src/types/personalRoomsTypes";
|
||||||
|
import { Ship } from "@/src/models/shipModel";
|
||||||
|
|
||||||
export const inventoryController: RequestHandler = async (request, response) => {
|
export const inventoryController: RequestHandler = async (request, response) => {
|
||||||
const account = await getAccountForRequest(request);
|
const account = await getAccountForRequest(request);
|
||||||
@ -133,13 +134,12 @@ export const getInventoryResponse = async (
|
|||||||
xpBasedLevelCapDisabled: boolean,
|
xpBasedLevelCapDisabled: boolean,
|
||||||
buildLabel: string | undefined
|
buildLabel: string | undefined
|
||||||
): Promise<IInventoryClient> => {
|
): Promise<IInventoryClient> => {
|
||||||
const inventoryWithLoadOutPresets = await inventory.populate<{ LoadOutPresets: ILoadoutDatabase }>(
|
const [inventoryWithLoadOutPresets, ships] = await Promise.all([
|
||||||
"LoadOutPresets"
|
inventory.populate<{ LoadOutPresets: ILoadoutDatabase }>("LoadOutPresets"),
|
||||||
);
|
Ship.find({ ShipOwnerId: inventory.accountOwnerId })
|
||||||
const inventoryWithLoadOutPresetsAndShips = await inventoryWithLoadOutPresets.populate<{ Ships: IShipInventory }>(
|
]);
|
||||||
"Ships"
|
const inventoryResponse = inventoryWithLoadOutPresets.toJSON<IInventoryClient>();
|
||||||
);
|
inventoryResponse.Ships = ships.map(x => x.toJSON<IShipInventory>());
|
||||||
const inventoryResponse = inventoryWithLoadOutPresetsAndShips.toJSON<IInventoryClient>();
|
|
||||||
|
|
||||||
if (config.infiniteCredits) {
|
if (config.infiniteCredits) {
|
||||||
inventoryResponse.RegularCredits = 999999999;
|
inventoryResponse.RegularCredits = 999999999;
|
||||||
|
@ -28,17 +28,15 @@ shipSchema.set("toJSON", {
|
|||||||
delete returnedObject._id;
|
delete returnedObject._id;
|
||||||
delete returnedObject.__v;
|
delete returnedObject.__v;
|
||||||
delete returnedObject.ShipOwnerId;
|
delete returnedObject.ShipOwnerId;
|
||||||
if (shipDatabase.ShipExteriorColors) {
|
|
||||||
shipResponse.ShipExterior = {
|
|
||||||
Colors: shipDatabase.ShipExteriorColors,
|
|
||||||
ShipAttachments: shipDatabase.ShipAttachments,
|
|
||||||
SkinFlavourItem: shipDatabase.SkinFlavourItem
|
|
||||||
};
|
|
||||||
|
|
||||||
delete shipDatabase.ShipExteriorColors;
|
shipResponse.ShipExterior = {
|
||||||
delete shipDatabase.ShipAttachments;
|
Colors: shipDatabase.ShipExteriorColors,
|
||||||
delete shipDatabase.SkinFlavourItem;
|
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 {
|
export interface IShipExterior {
|
||||||
SkinFlavourItem?: string;
|
SkinFlavourItem?: string;
|
||||||
Colors: IColor;
|
Colors?: IColor;
|
||||||
ShipAttachments?: IShipAttachments;
|
ShipAttachments?: IShipAttachments;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
Loading…
x
Reference in New Issue
Block a user