2024-05-16 01:34:38 +02:00
|
|
|
import { RequestHandler } from "express";
|
|
|
|
import { Types } from "mongoose";
|
|
|
|
import { Guild } from "@/src/models/guildModel";
|
2025-02-11 20:11:31 -08:00
|
|
|
import { getDojoClient } from "@/src/services/guildService";
|
2024-05-16 01:34:38 +02:00
|
|
|
|
|
|
|
export const getGuildDojoController: RequestHandler = async (req, res) => {
|
|
|
|
const guildId = req.query.guildId as string;
|
|
|
|
|
2025-03-24 11:32:08 -07:00
|
|
|
const guild = await Guild.findById(guildId);
|
2024-05-16 01:34:38 +02:00
|
|
|
if (!guild) {
|
|
|
|
res.status(404).end();
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
|
|
|
|
// Populate dojo info if not present
|
2025-03-03 05:46:16 -08:00
|
|
|
if (guild.DojoComponents.length == 0) {
|
2025-03-04 19:31:09 +01:00
|
|
|
guild.DojoComponents.push({
|
|
|
|
_id: new Types.ObjectId(),
|
|
|
|
pf: "/Lotus/Levels/ClanDojo/DojoHall.level",
|
|
|
|
ppf: "",
|
2025-03-05 23:54:47 -08:00
|
|
|
CompletionTime: new Date(Date.now()),
|
|
|
|
DecoCapacity: 600
|
2025-03-04 19:31:09 +01:00
|
|
|
});
|
2024-06-01 13:03:27 +02:00
|
|
|
await guild.save();
|
2024-05-16 01:34:38 +02:00
|
|
|
}
|
|
|
|
|
2025-03-09 11:16:17 -07:00
|
|
|
const payload: IGetGuildDojoRequest = req.body ? (JSON.parse(String(req.body)) as IGetGuildDojoRequest) : {};
|
|
|
|
res.json(await getDojoClient(guild, 0, payload.ComponentId));
|
2024-05-16 01:34:38 +02:00
|
|
|
};
|
2025-03-09 11:16:17 -07:00
|
|
|
|
|
|
|
interface IGetGuildDojoRequest {
|
|
|
|
ComponentId?: string;
|
|
|
|
}
|