SpaceNinjaServer/src/controllers/api/giveKeyChainTriggeredMessageController.ts
AMelonInsideLemon 62570177b6 fix: handle quest replay (#2778)
Closes #2496

Reviewed-on: OpenWF/SpaceNinjaServer#2778
Reviewed-by: Sainan <63328889+sainan@users.noreply.github.com>
Co-authored-by: AMelonInsideLemon <166175391+AMelonInsideLemon@users.noreply.github.com>
Co-committed-by: AMelonInsideLemon <166175391+AMelonInsideLemon@users.noreply.github.com>
2025-09-14 23:31:35 -07:00

17 lines
753 B
TypeScript

import { getInventory } from "../../services/inventoryService.ts";
import { getAccountIdForRequest } from "../../services/loginService.ts";
import { giveKeyChainMessage } from "../../services/questService.ts";
import type { IKeyChainRequest } from "../../types/requestTypes.ts";
import type { 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 accountOwnerId");
await giveKeyChainMessage(inventory, keyChainInfo);
await inventory.save();
res.send(1);
};