返回提交历史
Modified
src/controllers/api/placeDecoInComponentController.ts
+6
-5
XFEstudio/XFESpaceNinjaServer
feat: handle placeDecoInComponent request from U10 (#3427)
Closes #3420 Reviewed-on: https://onlyg.it/OpenWF/SpaceNinjaServer/pulls/3427 Co-authored-by: Sainan <63328889+Sainan@users.noreply.github.com> Co-committed-by: Sainan <63328889+Sainan@users.noreply.github.com>
90c7b99b
代码差异
1 个文件
+6
-5
@@ -8,14 +8,15 @@ import {
8
8
scaleRequiredCount
9
9
} from "../../services/guildService.ts";
10
10
import { getInventory } from "../../services/inventoryService.ts";
11
import { getAccountIdForRequest } from "../../services/loginService.ts";
11
import { getAccountForRequest } from "../../services/loginService.ts";
12
12
import { GuildPermission } from "../../types/guildTypes.ts";
13
13
import type { RequestHandler } from "express";
14
14
import { Types } from "mongoose";
15
15
import { ExportDojoRecipes, ExportResources } from "warframe-public-export-plus";
16
16
17
17
export const placeDecoInComponentController: RequestHandler = async (req, res) => {
18
const accountId = await getAccountIdForRequest(req);
18
const account = await getAccountForRequest(req);
19
const accountId = account._id.toString();
19
20
const inventory = await getInventory(accountId, "GuildId LevelKeys");
20
21
const guild = await getGuildForRequestEx(req, inventory);
21
22
if (!hasAccessToDojo(inventory) || !(await hasGuildPermission(guild, accountId, GuildPermission.Decorator))) {
@@ -23,7 +24,7 @@ export const placeDecoInComponentController: RequestHandler = async (req, res) =
23
24
return;
24
25
}
25
26
const request = JSON.parse(String(req.body)) as IPlaceDecoInComponentRequest;
26
const component = guild.DojoComponents.id(request.ComponentId)!;
27
const component = guild.DojoComponents.id(request.ComponentId ?? (req.query.componentId as string))!;
27
28
28
29
if (component.DecoCapacity === undefined) {
29
30
component.DecoCapacity = Object.values(ExportDojoRecipes.rooms).find(
@@ -119,11 +120,11 @@ export const placeDecoInComponentController: RequestHandler = async (req, res) =
119
120
}
120
121
121
122
await guild.save();
122
res.json(await getDojoClient(guild, 0, component._id));
123
res.json(await getDojoClient(guild, 0, component._id, account.BuildLabel));
123
124
};
124
125
125
126
interface IPlaceDecoInComponentRequest {
126
ComponentId: string;
127
ComponentId?: string; // req.query.componentId in U10
127
128
Revision: number;
128
129
Type: string;
129
130
Pos: number[];