diff --git a/assets/openapi.json b/assets/openapi.json index 74dd2ade4..e5c7f6c23 100644 Binary files a/assets/openapi.json and b/assets/openapi.json differ diff --git a/assets/schemas.json b/assets/schemas.json index 135656f06..a31541225 100644 Binary files a/assets/schemas.json and b/assets/schemas.json differ 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