feat: hubBlessing.php (#1335)
Reviewed-on: OpenWF/SpaceNinjaServer#1335
This commit is contained in:
parent
049f709713
commit
401f1ed229
45
src/controllers/api/hubBlessingController.ts
Normal file
45
src/controllers/api/hubBlessingController.ts
Normal file
@ -0,0 +1,45 @@
|
||||
import { getJSONfromString } from "@/src/helpers/stringHelpers";
|
||||
import { addBooster, getInventory } from "@/src/services/inventoryService";
|
||||
import { getAccountIdForRequest } from "@/src/services/loginService";
|
||||
import { getRandomInt } from "@/src/services/rngService";
|
||||
import { RequestHandler } from "express";
|
||||
import { ExportBoosters } from "warframe-public-export-plus";
|
||||
|
||||
export const hubBlessingController: RequestHandler = async (req, res) => {
|
||||
const accountId = await getAccountIdForRequest(req);
|
||||
const data = getJSONfromString<IHubBlessingRequest>(String(req.body));
|
||||
const boosterType = ExportBoosters[data.booster].typeName;
|
||||
if (req.query.mode == "send") {
|
||||
const inventory = await getInventory(accountId, "BlessingCooldown Boosters");
|
||||
inventory.BlessingCooldown = new Date(Date.now() + 86400000);
|
||||
addBooster(boosterType, 3 * 3600, inventory);
|
||||
await inventory.save();
|
||||
|
||||
let token = "";
|
||||
for (let i = 0; i != 32; ++i) {
|
||||
token += getRandomInt(0, 15).toString(16);
|
||||
}
|
||||
|
||||
res.json({
|
||||
BlessingCooldown: inventory.BlessingCooldown,
|
||||
SendTime: Math.trunc(Date.now() / 1000).toString(),
|
||||
Token: token
|
||||
});
|
||||
} else {
|
||||
const inventory = await getInventory(accountId, "Boosters");
|
||||
addBooster(boosterType, 3 * 3600, inventory);
|
||||
await inventory.save();
|
||||
|
||||
res.json({
|
||||
BoosterType: data.booster,
|
||||
Sender: data.senderId
|
||||
});
|
||||
}
|
||||
};
|
||||
|
||||
interface IHubBlessingRequest {
|
||||
booster: string;
|
||||
senderId?: string; // mode=request
|
||||
sendTime?: string; // mode=request
|
||||
token?: string; // mode=request
|
||||
}
|
@ -57,6 +57,7 @@ import { giveQuestKeyRewardController } from "@/src/controllers/api/giveQuestKey
|
||||
import { giveStartingGearController } from "@/src/controllers/api/giveStartingGearController";
|
||||
import { guildTechController } from "@/src/controllers/api/guildTechController";
|
||||
import { hostSessionController } from "@/src/controllers/api/hostSessionController";
|
||||
import { hubBlessingController } from "@/src/controllers/api/hubBlessingController";
|
||||
import { hubController } from "@/src/controllers/api/hubController";
|
||||
import { hubInstancesController } from "@/src/controllers/api/hubInstancesController";
|
||||
import { inboxController } from "@/src/controllers/api/inboxController";
|
||||
@ -207,6 +208,7 @@ apiRouter.post("/giveQuestKeyReward.php", giveQuestKeyRewardController);
|
||||
apiRouter.post("/giveStartingGear.php", giveStartingGearController);
|
||||
apiRouter.post("/guildTech.php", guildTechController);
|
||||
apiRouter.post("/hostSession.php", hostSessionController);
|
||||
apiRouter.post("/hubBlessing.php", hubBlessingController);
|
||||
apiRouter.post("/infestedFoundry.php", infestedFoundryController);
|
||||
apiRouter.post("/inventorySlots.php", inventorySlotsController);
|
||||
apiRouter.post("/joinSession.php", joinSessionController);
|
||||
|
Loading…
x
Reference in New Issue
Block a user