fix: handle setPlacedDecoInfo for non-ship boot locations (#2349)
All checks were successful
Build / build (push) Successful in 56s
Build Docker image / docker-arm64 (push) Successful in 1m1s
Build Docker image / docker-amd64 (push) Successful in 1m15s

Closes #2347

Reviewed-on: #2349
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-06-29 09:08:44 -07:00 committed by Sainan
parent d66f1c58d8
commit 69f9d5ebc5
2 changed files with 20 additions and 5 deletions

View File

@ -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<void> => {
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;

View File

@ -154,7 +154,7 @@ export interface ISetPlacedDecoInfoRequest {
DecoId: string;
Room: string;
PictureFrameInfo: IPictureFrameInfo;
BootLocation?: string;
BootLocation?: TBootLocation;
ComponentId?: string;
GuildId?: string;
}