SpaceNinjaServer/src/controllers/api/giveKeyChainTriggeredMessageController.ts

17 lines
761 B
TypeScript
Raw Normal View History

2025-01-31 17:24:42 +01:00
import { IKeyChainRequest } from "@/src/controllers/api/giveKeyChainTriggeredItemsController";
import { getInventory } from "@/src/services/inventoryService";
import { getAccountIdForRequest } from "@/src/services/loginService";
import { giveKeyChainMessage } from "@/src/services/questService";
2025-01-31 17:24:42 +01:00
import { RequestHandler } from "express";
export const giveKeyChainTriggeredMessageController: RequestHandler = async (req, res) => {
const accountId = await getAccountIdForRequest(req);
const keyChainInfo = JSON.parse((req.body as Buffer).toString()) as IKeyChainRequest;
const inventory = await getInventory(accountId, "QuestKeys");
await giveKeyChainMessage(inventory, accountId, keyChainInfo);
2025-01-31 17:24:42 +01:00
await inventory.save();
res.send(1);
};