forked from OpenWF/SpaceNinjaServer
For bootstrapper v0.11.11, out now. Reviewed-on: OpenWF/SpaceNinjaServer#2735 Co-authored-by: Sainan <63328889+Sainan@users.noreply.github.com> Co-committed-by: Sainan <63328889+Sainan@users.noreply.github.com>
23 lines
984 B
TypeScript
23 lines
984 B
TypeScript
import { getInventory } from "../../services/inventoryService.ts";
|
|
import { getAccountIdForRequest } from "../../services/loginService.ts";
|
|
import { sendWsBroadcastTo } from "../../services/wsService.ts";
|
|
import type { IAccountCheats } from "../../types/inventoryTypes/inventoryTypes.ts";
|
|
import type { RequestHandler } from "express";
|
|
|
|
export const setAccountCheatController: RequestHandler = async (req, res) => {
|
|
const accountId = await getAccountIdForRequest(req);
|
|
const payload = req.body as ISetAccountCheatRequest;
|
|
const inventory = await getInventory(accountId, payload.key);
|
|
inventory[payload.key] = payload.value;
|
|
await inventory.save();
|
|
res.end();
|
|
if (["infiniteCredits", "infinitePlatinum", "infiniteEndo", "infiniteRegalAya"].indexOf(payload.key) != -1) {
|
|
sendWsBroadcastTo(accountId, { update_inventory: true, sync_inventory: true });
|
|
}
|
|
};
|
|
|
|
interface ISetAccountCheatRequest {
|
|
key: keyof IAccountCheats;
|
|
value: boolean;
|
|
}
|