SpaceNinjaServer/src/controllers/api/abortDojoComponentDestructionController.ts
Sainan c97c22b434
All checks were successful
Build Docker image / docker-arm64 (push) Successful in 1m15s
Build / build (push) Successful in 1m8s
Build Docker image / docker-amd64 (push) Successful in 1m1s
chore: use relative imports with .ts (#2694)
Reviewed-on: #2694
Co-authored-by: Sainan <63328889+Sainan@users.noreply.github.com>
Co-committed-by: Sainan <63328889+Sainan@users.noreply.github.com>
2025-08-25 13:37:14 -07:00

27 lines
1.0 KiB
TypeScript

import {
getDojoClient,
getGuildForRequestEx,
hasAccessToDojo,
hasGuildPermission
} from "../../services/guildService.ts";
import { getInventory } from "../../services/inventoryService.ts";
import { getAccountIdForRequest } from "../../services/loginService.ts";
import { GuildPermission } from "../../types/guildTypes.ts";
import type { RequestHandler } from "express";
export const abortDojoComponentDestructionController: RequestHandler = async (req, res) => {
const accountId = await getAccountIdForRequest(req);
const inventory = await getInventory(accountId, "GuildId LevelKeys");
const guild = await getGuildForRequestEx(req, inventory);
if (!hasAccessToDojo(inventory) || !(await hasGuildPermission(guild, accountId, GuildPermission.Architect))) {
res.json({ DojoRequestStatus: -1 });
return;
}
const componentId = req.query.componentId as string;
guild.DojoComponents.id(componentId)!.DestructionTime = undefined;
await guild.save();
res.json(await getDojoClient(guild, 0, componentId));
};