返回提交历史
Added
src/controllers/api/setHubNpcCustomizationsController.ts
+21
-0
Modified
src/models/inventoryModels/inventoryModel.ts
+14
-2
Modified
src/routes/api.ts
+2
-0
Modified
src/types/inventoryTypes/inventoryTypes.ts
+7
-0
XFEstudio/SpaceNinjaServer
feat: setHubNpcCustomizations (#1762)
Closes #1757 Reviewed-on: https://onlyg.it/OpenWF/SpaceNinjaServer/pulls/1762 Co-authored-by: Sainan <63328889+Sainan@users.noreply.github.com> Co-committed-by: Sainan <63328889+Sainan@users.noreply.github.com>
ec6729db
代码差异
4 个文件
+44
-2
@@ -0,0 +1,21 @@
1
import { getJSONfromString } from "@/src/helpers/stringHelpers";
2
import { getInventory } from "@/src/services/inventoryService";
3
import { getAccountIdForRequest } from "@/src/services/loginService";
4
import { IHubNpcCustomization } from "@/src/types/inventoryTypes/inventoryTypes";
5
import { RequestHandler } from "express";
6
7
export const setHubNpcCustomizationsController: RequestHandler = async (req, res) => {
8
const accountId = await getAccountIdForRequest(req);
9
const inventory = await getInventory(accountId, "HubNpcCustomizations");
10
const upload = getJSONfromString<IHubNpcCustomization>(String(req.body));
11
inventory.HubNpcCustomizations ??= [];
12
const cust = inventory.HubNpcCustomizations.find(x => x.Tag == upload.Tag);
13
if (cust) {
14
cust.Colors = upload.Colors;
15
cust.Pattern = upload.Pattern;
16
} else {
17
inventory.HubNpcCustomizations.push(upload);
18
}
19
await inventory.save();
20
res.end();
21
};
@@ -95,7 +95,8 @@ import {
95
95
ISortieRewardAttenuation,
96
96
IInvasionProgressDatabase,
97
97
IInvasionProgressClient,
98
IAccolades
98
IAccolades,
99
IHubNpcCustomization
99
100
} from "../../types/inventoryTypes/inventoryTypes";
100
101
import { IOid } from "../../types/commonTypes";
101
102
import {
@@ -1327,6 +1328,15 @@ const lockedWeaponGroupSchema = new Schema<ILockedWeaponGroupDatabase>(
1327
1328
{ _id: false }
1328
1329
);
1329
1330
1331
const hubNpcCustomizationSchema = new Schema<IHubNpcCustomization>(
1332
{
1333
Colors: colorSchema,
1334
Pattern: String,
1335
Tag: String
1336
},
1337
{ _id: false }
1338
);
1339
1330
1340
const inventorySchema = new Schema<IInventoryDatabase, InventoryDocumentProps>(
1331
1341
{
1332
1342
accountOwnerId: Schema.Types.ObjectId,
@@ -1680,7 +1690,9 @@ const inventorySchema = new Schema<IInventoryDatabase, InventoryDocumentProps>(
1680
1690
1681
1691
// G3 + Zanuka
1682
1692
BrandedSuits: { type: [Schema.Types.ObjectId], default: undefined },
1683
LockedWeaponGroup: { type: lockedWeaponGroupSchema, default: undefined }
1693
LockedWeaponGroup: { type: lockedWeaponGroupSchema, default: undefined },
1694
1695
HubNpcCustomizations: { type: [hubNpcCustomizationSchema], default: undefined }
1684
1696
},
1685
1697
{ timestamps: { createdAt: "Created", updatedAt: false } }
1686
1698
);
@@ -117,6 +117,7 @@ import { setDojoComponentMessageController } from "@/src/controllers/api/setDojo
117
117
import { setDojoComponentSettingsController } from "@/src/controllers/api/setDojoComponentSettingsController";
118
118
import { setEquippedInstrumentController } from "@/src/controllers/api/setEquippedInstrumentController";
119
119
import { setGuildMotdController } from "@/src/controllers/api/setGuildMotdController";
120
import { setHubNpcCustomizationsController } from "@/src/controllers/api/setHubNpcCustomizationsController";
120
121
import { setPlacedDecoInfoController } from "@/src/controllers/api/setPlacedDecoInfoController";
121
122
import { setShipCustomizationsController } from "@/src/controllers/api/setShipCustomizationsController";
122
123
import { setShipFavouriteLoadoutController } from "@/src/controllers/api/setShipFavouriteLoadoutController";
@@ -285,6 +286,7 @@ apiRouter.post("/setDojoComponentMessage.php", setDojoComponentMessageController
285
286
apiRouter.post("/setDojoComponentSettings.php", setDojoComponentSettingsController);
286
287
apiRouter.post("/setEquippedInstrument.php", setEquippedInstrumentController);
287
288
apiRouter.post("/setGuildMotd.php", setGuildMotdController);
289
apiRouter.post("/setHubNpcCustomizations.php", setHubNpcCustomizationsController);
288
290
apiRouter.post("/setPlacedDecoInfo.php", setPlacedDecoInfoController);
289
291
apiRouter.post("/setShipCustomizations.php", setShipCustomizationsController);
290
292
apiRouter.post("/setShipFavouriteLoadout.php", setShipFavouriteLoadoutController);
@@ -368,6 +368,7 @@ export interface IInventoryClient extends IDailyAffiliations, InventoryClientEqu
368
368
EchoesHexConquestActiveStickers?: string[];
369
369
BrandedSuits?: IOid[];
370
370
LockedWeaponGroup?: ILockedWeaponGroupClient;
371
HubNpcCustomizations?: IHubNpcCustomization[];
371
372
}
372
373
373
374
export interface IAffiliation {
@@ -1228,3 +1229,9 @@ export interface ILockedWeaponGroupDatabase {
1228
1229
}
1229
1230
1230
1231
export type TPartialStartingGear = Pick<IInventoryClient, "LongGuns" | "Suits" | "Pistols" | "Melee">;
1232
1233
export interface IHubNpcCustomization {
1234
Colors?: IColor;
1235
Pattern: string;
1236
Tag: string;
1237
}