SpaceNinjaServer/src/controllers/api/abortDojoComponentController.ts
Sainan c4ab496aa3
All checks were successful
Build / build (22) (push) Successful in 37s
Build / build (20) (push) Successful in 55s
Build / build (18) (push) Successful in 52s
Build Docker image / docker (push) Successful in 32s
feat: dojo decorations (#1079)
Closes #525

Reviewed-on: #1079
2025-03-05 23:54:47 -08:00

28 lines
1.0 KiB
TypeScript

import { getDojoClient, getGuildForRequestEx, removeDojoDeco, removeDojoRoom } from "@/src/services/guildService";
import { getInventory } from "@/src/services/inventoryService";
import { getAccountIdForRequest } from "@/src/services/loginService";
import { RequestHandler } from "express";
export const abortDojoComponentController: RequestHandler = async (req, res) => {
const accountId = await getAccountIdForRequest(req);
const inventory = await getInventory(accountId);
const guild = await getGuildForRequestEx(req, inventory);
const request = JSON.parse(String(req.body)) as IAbortDojoComponentRequest;
// TODO: Move already-contributed credits & items to the clan vault
if (request.DecoId) {
removeDojoDeco(guild, request.ComponentId, request.DecoId);
} else {
removeDojoRoom(guild, request.ComponentId);
}
await guild.save();
res.json(getDojoClient(guild, 0, request.ComponentId));
};
interface IAbortDojoComponentRequest {
DecoType?: string;
ComponentId: string;
DecoId?: string;
}