From 14d59653d70c9649ae8851942e845e57eb7cc87a Mon Sep 17 00:00:00 2001 From: Rory& Date: Mon, 31 Aug 2026 04:29:33 +0200 Subject: [PATCH] Document audit log endpoint somewhat --- assets/openapi.json | Bin 1061137 -> 1065567 bytes assets/schemas.json | Bin 484397 -> 486030 bytes src/api/routes/guilds/#guild_id/audit-logs.ts | 70 +++++++++++++++--- src/schemas/api/guilds/AuditLog.ts | 13 +++- 4 files changed, 70 insertions(+), 13 deletions(-) diff --git a/assets/openapi.json b/assets/openapi.json index 74dd2ade45f3ec7b3534c006e86601a818e3c377..e5c7f6c2304d182d0206e7daf57c5dbe74bb95d1 100644 GIT binary patch delta 759 zcmZvaUr1A77{>W_{%q&CvuVzB&hkSIF=;AM5OlEv3mrO|G=mB}o9^2j&YkV-EHu1m zF%Y^^4)rF*km{l!azwBU`g4&aT`6>5)P1-+ucYsc8acZ7UA*7>ybsUE`>y@)eJjeh zi>PRM%}keUaz2*SC)5PA5EOGn%}PnB35BF}%~%_}0^bYl2z(r41UNj2ypVZ@PMdE- z5J4O(EvPY~MfIebR0g~%%lYwWgK zjqA52O+T-pJmrni$Nhj0tZ`V~vi1P}VE4fAUETvRKdLoSaQKPo{L|RsJD`;1*5Oy# z)&rS4&WqrCZ|Q}NDfSo?7LmK*JFs`actAlMcQiIs*OBL+q*6QYuIGdJF6%b4LG?Lz z0+?0Q0gtkr2v26w`4v)PC@h7e@DwY>MiD3?rKv(n_VE|6-(q*eew%|6V><5(lPd`gFIMY;i* zgfIY(9r1JbRF2vO{H8#kBRFrCdUQUSPSk4H*tB*TzM*y){$lIp^{AF0`n^5jRBgKN z|I?<1#PG~ggT=nv(T8S1F0%N3*4boQEH~tJg_knK3{$&TOz#zwn^1kj)6iQ=ei2b~i?e*-og5p)0m delta 88 zcmccL;yCe6aTyNB(v-{+pZxUc2VEI`c|n}`oc#3o)Vz|S$%Q8*CO2?v zPxrgatTadZ9Iw$YcQvmgxxV@aYef*_98CL()bx`HdS$n*ymY^;JPZp=w7R+{X%Mik6ahd5CBG_5mYn7ORm<5PIY_{#SO6-Cj07-ofvj6}9 diff --git a/src/api/routes/guilds/#guild_id/audit-logs.ts b/src/api/routes/guilds/#guild_id/audit-logs.ts index e8765a99b..2f99aea00 100644 --- a/src/api/routes/guilds/#guild_id/audit-logs.ts +++ b/src/api/routes/guilds/#guild_id/audit-logs.ts @@ -1,6 +1,6 @@ /* Spacebar: A FOSS re-implementation and extension of the Discord.com backend. - Copyright (C) 2023 Spacebar and Spacebar Contributors + Copyright (C) 2026 Spacebar and Spacebar Contributors This program is free software: you can redistribute it and/or modify it under the terms of the GNU Affero General Public License as published @@ -18,18 +18,64 @@ import { Router, Response, Request } from "express"; import { route } from "@spacebar/api/middlewares"; +import { AuditLogResponse } from "@spacebar/schemas"; const router = Router({ mergeParams: true }); //TODO: implement audit logs -router.get("/", route({}), (req: Request, res: Response) => { - res.json({ - audit_log_entries: [], - users: [], - integrations: [], - webhooks: [], - guild_scheduled_events: [], - threads: [], - application_commands: [], - }); -}); +router.get( + "/", + route({ + permission: "VIEW_AUDIT_LOG", + query: { + before: { + required: false, + type: "string", + description: "Entries before this ID", + }, + after: { + required: false, + type: "string", + description: "Entries after this ID", + }, + limit: { + required: false, + type: "number", + description: "Amount of results to return", + default: 50, + }, + user_id: { + required: false, + type: "string", + description: "User ID of the user taking the action", + }, + target_id: { + required: false, + type: "string", + description: "User ID of the user targeted by the action", + }, + action_type: { + required: false, + type: "number", + description: "Type of audit log event", + }, + }, + responses: { + 200: { + body: "AuditLogResponse", + }, + }, + }), + (req: Request, res: Response) => { + res.json({ + audit_log_entries: [], + users: [], + integrations: [], + webhooks: [], + guild_scheduled_events: [], + threads: [], + application_commands: [], + auto_moderation_rules: [], + } satisfies AuditLogResponse); + }, +); export default router; diff --git a/src/schemas/api/guilds/AuditLog.ts b/src/schemas/api/guilds/AuditLog.ts index 9908d73ff..2c4f692c8 100644 --- a/src/schemas/api/guilds/AuditLog.ts +++ b/src/schemas/api/guilds/AuditLog.ts @@ -16,7 +16,18 @@ along with this program. If not, see . */ -import { ChannelPermissionOverwrite } from "@spacebar/schemas"; +import { AutomodRuleSchema, ChannelPermissionOverwrite, PartialUser, PublicChannel, WebhookResponse } from "@spacebar/schemas"; + +export interface AuditLogResponse { + audit_log_entries: unknown[]; // TODO: type + application_commands: unknown[]; // TODO: type + auto_moderation_rules: AutomodRuleSchema[]; + guild_scheduled_events: unknown[]; // TODO: type + integrations: unknown[]; // TODO: type + threads: PublicChannel[]; + users: PartialUser[]; + webhooks: WebhookResponse[]; +} export enum AuditLogEvents { // guild level