From 69f9d5ebc5b52547fa7643aa714f198eecd78789 Mon Sep 17 00:00:00 2001 From: Sainan <63328889+Sainan@users.noreply.github.com> Date: Sun, 29 Jun 2025 09:08:44 -0700 Subject: [PATCH] fix: handle setPlacedDecoInfo for non-ship boot locations (#2349) Closes #2347 Reviewed-on: https://onlyg.it/OpenWF/SpaceNinjaServer/pulls/2349 Co-authored-by: Sainan <63328889+Sainan@users.noreply.github.com> Co-committed-by: Sainan <63328889+Sainan@users.noreply.github.com> --- src/services/shipCustomizationsService.ts | 23 +++++++++++++++++++---- src/types/shipTypes.ts | 2 +- 2 files changed, 20 insertions(+), 5 deletions(-) diff --git a/src/services/shipCustomizationsService.ts b/src/services/shipCustomizationsService.ts index 1e5dcf26..990fa13e 100644 --- a/src/services/shipCustomizationsService.ts +++ b/src/services/shipCustomizationsService.ts @@ -4,7 +4,8 @@ import { ISetShipCustomizationsRequest, IShipDecorationsRequest, IShipDecorationsResponse, - ISetPlacedDecoInfoRequest + ISetPlacedDecoInfoRequest, + TBootLocation } from "@/src/types/shipTypes"; import { logger } from "@/src/utils/logger"; import { Types } from "mongoose"; @@ -14,6 +15,7 @@ import { Guild } from "../models/guildModel"; import { hasGuildPermission } from "./guildService"; import { GuildPermission } from "../types/guildTypes"; import { ExportResources } from "warframe-public-export-plus"; +import { RoomsType, TPersonalRoomsDatabaseDocument } from "../types/personalRoomsTypes"; export const setShipCustomizations = async ( accountId: string, @@ -183,6 +185,19 @@ export const handleSetShipDecorations = async ( }; }; +const getRoomsForBootLocation = ( + personalRooms: TPersonalRoomsDatabaseDocument, + bootLocation: TBootLocation | undefined +): RoomsType[] => { + if (bootLocation == "SHOP") { + return personalRooms.TailorShop.Rooms; + } + if (bootLocation == "APARTMENT") { + return personalRooms.Apartment.Rooms; + } + return personalRooms.Ship.Rooms; +}; + export const handleSetPlacedDecoInfo = async (accountId: string, req: ISetPlacedDecoInfoRequest): Promise => { if (req.GuildId && req.ComponentId) { const guild = (await Guild.findById(req.GuildId))!; @@ -197,14 +212,14 @@ export const handleSetPlacedDecoInfo = async (accountId: string, req: ISetPlaced const personalRooms = await getPersonalRooms(accountId); - const room = personalRooms.Ship.Rooms.find(room => room.Name === req.Room); + const room = getRoomsForBootLocation(personalRooms, req.BootLocation).find(room => room.Name === req.Room); if (!room) { - throw new Error("room not found"); + throw new Error(`unknown room: ${req.Room}`); } const placedDeco = room.PlacedDecos.id(req.DecoId); if (!placedDeco) { - throw new Error("deco not found"); + throw new Error(`unknown deco id: ${req.DecoId}`); } placedDeco.PictureFrameInfo = req.PictureFrameInfo; diff --git a/src/types/shipTypes.ts b/src/types/shipTypes.ts index 6ac738b2..25555af7 100644 --- a/src/types/shipTypes.ts +++ b/src/types/shipTypes.ts @@ -154,7 +154,7 @@ export interface ISetPlacedDecoInfoRequest { DecoId: string; Room: string; PictureFrameInfo: IPictureFrameInfo; - BootLocation?: string; + BootLocation?: TBootLocation; ComponentId?: string; GuildId?: string; }