SpaceNinjaServer/src/controllers/api/abortDojoComponentController.ts
Sainan 77aa1caa8f
All checks were successful
Build / build (20) (push) Successful in 38s
Build / build (18) (push) Successful in 57s
Build / build (22) (push) Successful in 56s
Build Docker image / docker (push) Successful in 39s
feat: dojo room destruction stage (#1089)
Closes #1074

Based on what I could find, apparently only rooms need 2 hours to destroy and decos are removed instantly.

Reviewed-on: #1089
2025-03-06 07:19:01 -08:00

27 lines
997 B
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;
if (request.DecoId) {
removeDojoDeco(guild, request.ComponentId, request.DecoId);
} else {
removeDojoRoom(guild, request.ComponentId);
}
await guild.save();
res.json(await getDojoClient(guild, 0, request.ComponentId));
};
interface IAbortDojoComponentRequest {
DecoType?: string;
ComponentId: string;
DecoId?: string;
}