SpaceNinjaServer/src/controllers/api/getGuildDojoController.ts
Sainan 9da47c406a
Some checks failed
Build / build (push) Has been cancelled
Build Docker image / docker-arm64 (push) Has been cancelled
Build Docker image / docker-amd64 (push) Has been cancelled
fix: put CompletionTime of initial clan hall in the past (#2850)
For old versions, TimeRemaining of 0 would cause this to show in yellow, we need it to be negative.

Reviewed-on: #2850
Co-authored-by: Sainan <63328889+Sainan@users.noreply.github.com>
Co-committed-by: Sainan <63328889+Sainan@users.noreply.github.com>
2025-10-05 23:24:59 -07:00

36 lines
1.2 KiB
TypeScript

import type { RequestHandler } from "express";
import { Types } from "mongoose";
import { Guild } from "../../models/guildModel.ts";
import { getDojoClient } from "../../services/guildService.ts";
import { Account } from "../../models/loginModel.ts";
export const getGuildDojoController: RequestHandler = async (req, res) => {
const guildId = req.query.guildId as string;
const guild = await Guild.findById(guildId);
if (!guild) {
res.status(404).end();
return;
}
// Populate dojo info if not present
if (guild.DojoComponents.length == 0) {
guild.DojoComponents.push({
_id: new Types.ObjectId(),
pf: "/Lotus/Levels/ClanDojo/DojoHall.level",
ppf: "",
CompletionTime: new Date(Date.now() - 1000),
DecoCapacity: 600
});
await guild.save();
}
const payload: IGetGuildDojoRequest = req.body ? (JSON.parse(String(req.body)) as IGetGuildDojoRequest) : {};
const account = await Account.findById(req.query.accountId as string);
res.json(await getDojoClient(guild, 0, payload.ComponentId, account?.BuildLabel));
};
interface IGetGuildDojoRequest {
ComponentId?: string;
}