add giveQuestKey
All checks were successful
Build / build (22) (push) Successful in 1m22s
Build / build (20) (push) Successful in 1m23s
Build / build (18) (pull_request) Successful in 1m26s
Build / build (22) (pull_request) Successful in 52s
Build / build (20) (pull_request) Successful in 54s
Build / build (18) (push) Successful in 35s
All checks were successful
Build / build (22) (push) Successful in 1m22s
Build / build (20) (push) Successful in 1m23s
Build / build (18) (pull_request) Successful in 1m26s
Build / build (22) (pull_request) Successful in 52s
Build / build (20) (pull_request) Successful in 54s
Build / build (18) (push) Successful in 35s
This commit is contained in:
parent
6f8cf74add
commit
af6a466948
45
src/controllers/api/giveQuestKey.ts
Normal file
45
src/controllers/api/giveQuestKey.ts
Normal file
@ -0,0 +1,45 @@
|
|||||||
|
import { getJSONfromString } from "@/src/helpers/stringHelpers";
|
||||||
|
import { addItem, getInventory } from "@/src/services/inventoryService";
|
||||||
|
import { getAccountIdForRequest } from "@/src/services/loginService";
|
||||||
|
import { IOid } from "@/src/types/commonTypes";
|
||||||
|
import { RequestHandler } from "express";
|
||||||
|
|
||||||
|
export const giveQuestKeyRewardController: RequestHandler = async (req, res) => {
|
||||||
|
const accountId = await getAccountIdForRequest(req);
|
||||||
|
const rewardRequest = getJSONfromString<IQuestKeyRewardRequest>((req.body as Buffer).toString());
|
||||||
|
|
||||||
|
if (Array.isArray(rewardRequest.reward)) {
|
||||||
|
throw new Error("Multiple rewards not expected");
|
||||||
|
}
|
||||||
|
|
||||||
|
const reward = rewardRequest.reward;
|
||||||
|
const inventory = await getInventory(accountId);
|
||||||
|
const inventoryChanges = await addItem(inventory, reward.ItemType, reward.Amount);
|
||||||
|
await inventory.save();
|
||||||
|
res.json(inventoryChanges.InventoryChanges);
|
||||||
|
//TODO: consider whishlist changes
|
||||||
|
};
|
||||||
|
|
||||||
|
export interface IQuestKeyRewardRequest {
|
||||||
|
reward: IQuestKeyReward;
|
||||||
|
}
|
||||||
|
|
||||||
|
export interface IQuestKeyReward {
|
||||||
|
RewardType: string;
|
||||||
|
CouponType: string;
|
||||||
|
Icon: string;
|
||||||
|
ItemType: string;
|
||||||
|
StoreItemType: string;
|
||||||
|
ProductCategory: string;
|
||||||
|
Amount: number;
|
||||||
|
ScalingMultiplier: number;
|
||||||
|
Durability: string;
|
||||||
|
DisplayName: string;
|
||||||
|
Duration: number;
|
||||||
|
CouponSku: number;
|
||||||
|
Syndicate: string;
|
||||||
|
Milestones: any[];
|
||||||
|
ChooseSetIndex: number;
|
||||||
|
NewSystemReward: boolean;
|
||||||
|
_id: IOid;
|
||||||
|
}
|
@ -83,6 +83,7 @@ import { updateSessionGetController, updateSessionPostController } from "@/src/c
|
|||||||
import { updateThemeController } from "../controllers/api/updateThemeController";
|
import { updateThemeController } from "../controllers/api/updateThemeController";
|
||||||
import { upgradesController } from "@/src/controllers/api/upgradesController";
|
import { upgradesController } from "@/src/controllers/api/upgradesController";
|
||||||
import { giveKeyChainTriggeredMessageController } from "@/src/controllers/api/giveKeyChainTriggeredMessageController";
|
import { giveKeyChainTriggeredMessageController } from "@/src/controllers/api/giveKeyChainTriggeredMessageController";
|
||||||
|
import { giveQuestKeyRewardController } from "@/src/controllers/api/giveQuestKey";
|
||||||
|
|
||||||
const apiRouter = express.Router();
|
const apiRouter = express.Router();
|
||||||
|
|
||||||
@ -140,6 +141,7 @@ apiRouter.post("/getVoidProjectionRewards.php", getVoidProjectionRewardsControll
|
|||||||
apiRouter.post("/gildWeapon.php", gildWeaponController);
|
apiRouter.post("/gildWeapon.php", gildWeaponController);
|
||||||
apiRouter.post("/giveKeyChainTriggeredItems.php", giveKeyChainTriggeredItemsController);
|
apiRouter.post("/giveKeyChainTriggeredItems.php", giveKeyChainTriggeredItemsController);
|
||||||
apiRouter.post("/giveKeyChainTriggeredMessage.php", giveKeyChainTriggeredMessageController);
|
apiRouter.post("/giveKeyChainTriggeredMessage.php", giveKeyChainTriggeredMessageController);
|
||||||
|
apiRouter.post("/giveQuestKeyReward.php", giveQuestKeyRewardController);
|
||||||
apiRouter.post("/guildTech.php", guildTechController);
|
apiRouter.post("/guildTech.php", guildTechController);
|
||||||
apiRouter.post("/hostSession.php", hostSessionController);
|
apiRouter.post("/hostSession.php", hostSessionController);
|
||||||
apiRouter.post("/infestedFoundry.php", infestedFoundryController);
|
apiRouter.post("/infestedFoundry.php", infestedFoundryController);
|
||||||
|
Loading…
x
Reference in New Issue
Block a user