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";
|
2025-02-19 14:09:47 -08:00
|
|
|
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");
|
2025-02-19 14:09:47 -08:00
|
|
|
await giveKeyChainMessage(inventory, accountId, keyChainInfo);
|
2025-01-31 17:24:42 +01:00
|
|
|
await inventory.save();
|
|
|
|
|
|
|
|
res.send(1);
|
|
|
|
};
|