XFE Git
XFE Studio Git
Git 首页 全局搜索
XFE 主站 文档 NuGet

SpaceNinjaServer

A simple server for a small space ninja game

公开
关注 0 Fork 1 Star 0
返回提交历史

XFEstudio/SpaceNinjaServer

feat: hubBlessing.php (#1335)

Reviewed-on: https://onlyg.it/OpenWF/SpaceNinjaServer/pulls/1335

401f1ed2
Sainan <sainan@calamity.inc>
提交于

代码差异

2 个文件 +47 -0
Added src/controllers/api/hubBlessingController.ts +45 -0
@@ -0,0 +1,45 @@
1 import { getJSONfromString } from "@/src/helpers/stringHelpers";
2 import { addBooster, getInventory } from "@/src/services/inventoryService";
3 import { getAccountIdForRequest } from "@/src/services/loginService";
4 import { getRandomInt } from "@/src/services/rngService";
5 import { RequestHandler } from "express";
6 import { ExportBoosters } from "warframe-public-export-plus";
7
8 export const hubBlessingController: RequestHandler = async (req, res) => {
9 const accountId = await getAccountIdForRequest(req);
10 const data = getJSONfromString<IHubBlessingRequest>(String(req.body));
11 const boosterType = ExportBoosters[data.booster].typeName;
12 if (req.query.mode == "send") {
13 const inventory = await getInventory(accountId, "BlessingCooldown Boosters");
14 inventory.BlessingCooldown = new Date(Date.now() + 86400000);
15 addBooster(boosterType, 3 * 3600, inventory);
16 await inventory.save();
17
18 let token = "";
19 for (let i = 0; i != 32; ++i) {
20 token += getRandomInt(0, 15).toString(16);
21 }
22
23 res.json({
24 BlessingCooldown: inventory.BlessingCooldown,
25 SendTime: Math.trunc(Date.now() / 1000).toString(),
26 Token: token
27 });
28 } else {
29 const inventory = await getInventory(accountId, "Boosters");
30 addBooster(boosterType, 3 * 3600, inventory);
31 await inventory.save();
32
33 res.json({
34 BoosterType: data.booster,
35 Sender: data.senderId
36 });
37 }
38 };
39
40 interface IHubBlessingRequest {
41 booster: string;
42 senderId?: string; // mode=request
43 sendTime?: string; // mode=request
44 token?: string; // mode=request
45 }
Modified src/routes/api.ts +2 -0
@@ -57,6 +57,7 @@ import { giveQuestKeyRewardController } from "@/src/controllers/api/giveQuestKey
57 57 import { giveStartingGearController } from "@/src/controllers/api/giveStartingGearController";
58 58 import { guildTechController } from "@/src/controllers/api/guildTechController";
59 59 import { hostSessionController } from "@/src/controllers/api/hostSessionController";
60 import { hubBlessingController } from "@/src/controllers/api/hubBlessingController";
60 61 import { hubController } from "@/src/controllers/api/hubController";
61 62 import { hubInstancesController } from "@/src/controllers/api/hubInstancesController";
62 63 import { inboxController } from "@/src/controllers/api/inboxController";
@@ -207,6 +208,7 @@ apiRouter.post("/giveQuestKeyReward.php", giveQuestKeyRewardController);
207 208 apiRouter.post("/giveStartingGear.php", giveStartingGearController);
208 209 apiRouter.post("/guildTech.php", guildTechController);
209 210 apiRouter.post("/hostSession.php", hostSessionController);
211 apiRouter.post("/hubBlessing.php", hubBlessingController);
210 212 apiRouter.post("/infestedFoundry.php", infestedFoundryController);
211 213 apiRouter.post("/inventorySlots.php", inventorySlotsController);
212 214 apiRouter.post("/joinSession.php", joinSessionController);