From 4ea2f59947df105cd48373924535fc0723df4ce2 Mon Sep 17 00:00:00 2001 From: Master Date: Tue, 11 Mar 2025 20:37:30 -0700 Subject: [PATCH] =?UTF-8?q?=E6=9B=B4=E6=96=B0=20src/controllers/api/getGui?= =?UTF-8?q?ldLogController.ts?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- src/controllers/api/getGuildLogController.ts | 20 ++++++++++++-------- 1 file changed, 12 insertions(+), 8 deletions(-) diff --git a/src/controllers/api/getGuildLogController.ts b/src/controllers/api/getGuildLogController.ts index 2919ce31..72b67bcf 100644 --- a/src/controllers/api/getGuildLogController.ts +++ b/src/controllers/api/getGuildLogController.ts @@ -1,11 +1,15 @@ +import { getGuildForGuildId, getGuildLog } from "@/src/services/guildService"; +import { getInventory } from "@/src/services/inventoryService"; +import { getAccountIdForRequest } from "@/src/services/loginService"; import { RequestHandler } from "express"; -export const getGuildLogController: RequestHandler = (_req, res) => { - res.json({ - RoomChanges: [], - TechChanges: [], - RosterActivity: [], - StandingsUpdates: [], - ClassChanges: [] - }); +export const getGuildLogController: RequestHandler = async (req, res) => { + const accountId = await getAccountIdForRequest(req); + const inventory = await getInventory(accountId); + const guild = await getGuildForGuildId(inventory.GuildId?.toString() ?? ""); + if (!guild) { + res.status(400).json({ error: "guild was undefined" }); + return; + } + res.json(await getGuildLog(accountId, guild)); };