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;
|
|
|
|
|
|
|
|
const guild = await Guild.findOne({ _id: guildId });
|
|
|
|
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-06 07:19:01 -08:00
|
|
|
res.json(await getDojoClient(guild, 0));
|
2024-05-16 01:34:38 +02:00
|
|
|
};
|