SpaceNinjaServer/src/controllers/api/getGuildController.ts
Sainan fae6615df4 feat: clan members (#1143)
Now you can add/remove members and accept/decline invites.

Closes #1110

Reviewed-on: OpenWF/SpaceNinjaServer#1143
Co-authored-by: Sainan <sainan@calamity.inc>
Co-committed-by: Sainan <sainan@calamity.inc>
2025-03-10 16:40:40 -07:00

29 lines
1.1 KiB
TypeScript

import { RequestHandler } from "express";
import { Guild } from "@/src/models/guildModel";
import { getAccountIdForRequest } from "@/src/services/loginService";
import { logger } from "@/src/utils/logger";
import { getInventory } from "@/src/services/inventoryService";
import { getGuildClient } from "@/src/services/guildService";
const getGuildController: RequestHandler = async (req, res) => {
const accountId = await getAccountIdForRequest(req);
const inventory = await getInventory(accountId);
if (inventory.GuildId) {
const guild = await Guild.findOne({ _id: inventory.GuildId });
if (guild) {
if (guild.CeremonyResetDate && Date.now() >= guild.CeremonyResetDate.getTime()) {
logger.debug(`ascension ceremony is over`);
guild.CeremonyEndo = undefined;
guild.CeremonyContributors = undefined;
guild.CeremonyResetDate = undefined;
await guild.save();
}
res.json(await getGuildClient(guild, accountId));
return;
}
}
res.json({});
};
export { getGuildController };