SpaceNinjaServer/src/controllers/api/giveKeyChainTriggeredMessageController.ts
Ordis fb8d176fbe
All checks were successful
Build / build (18) (push) Successful in 58s
Build / build (20) (push) Successful in 1m8s
Build Docker image / docker (push) Successful in 1m25s
Build / build (22) (push) Successful in 32s
fix(webui): quest cheats (#965)
Completing Quests via the webui will now also award the quest's items and mails.

Also fixes doubly adding key chain items.
A few items will not be added, as it is currently impossible to determine the item category by path for these items.
This will be fixed soon.

Reviewed-on: #965
Co-authored-by: Ordis <134585663+OrdisPrime@users.noreply.github.com>
Co-committed-by: Ordis <134585663+OrdisPrime@users.noreply.github.com>
2025-02-19 14:09:47 -08:00

17 lines
761 B
TypeScript

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";
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);
await inventory.save();
res.send(1);
};