From 1a891e5898b4e4bde3f35b43965c613794503996 Mon Sep 17 00:00:00 2001 From: Regalijan Date: Sat, 11 Apr 2026 04:29:04 -0400 Subject: [PATCH] Even more migrations --- functions/api/game-bans/[user]/revoke.ts | 21 ++++++-------- functions/api/me/reports.ts | 35 +++++++++++++----------- 2 files changed, 28 insertions(+), 28 deletions(-) diff --git a/functions/api/game-bans/[user]/revoke.ts b/functions/api/game-bans/[user]/revoke.ts index 40c305e..614cb7e 100644 --- a/functions/api/game-bans/[user]/revoke.ts +++ b/functions/api/game-bans/[user]/revoke.ts @@ -18,18 +18,15 @@ export async function onRequestPost(context: RequestContext) { if (isNaN(parseInt(user))) return jsonError("Invalid user ID", 400); - await context.env.D1.prepare( - "INSERT INTO game_mod_logs (action, evidence, executed_at, executor, id, target) VALUES (?, ?, ?, ?, ?, ?);", - ) - .bind( - "revoke", - ticket_link, - Date.now(), - context.data.current_user.id, - crypto.randomUUID(), - parseInt(user), - ) - .run(); + await context.data.prisma.gameModLog.create({ + data: { + action: "revoke", + evidence: ticket_link, + executor: context.data.current_user.id, + id: crypto.randomUUID(), + target: parseInt(user), + }, + }); const { etag, value: banList } = await getBanList(context); diff --git a/functions/api/me/reports.ts b/functions/api/me/reports.ts index a6feb81..0d584b5 100644 --- a/functions/api/me/reports.ts +++ b/functions/api/me/reports.ts @@ -1,19 +1,22 @@ -import { jsonError, jsonResponse } from "../../common.js"; +import { jsonResponse } from "../../common.js"; export async function onRequestGet(context: RequestContext) { - const { - results, - success, - }: { - results: { id: string }[]; - success: boolean; - } = await context.env.D1.prepare( - "SELECT created_at, id, open, target_usernames FROM reports WHERE json_extract(user, '$.id') = ? ORDER BY created_at LIMIT 50;", - ) - .bind(context.data.current_user.id) - .all(); - - if (!success) return jsonError("Failed to retrieve reports", 500); - - return jsonResponse(JSON.stringify(results)); + return jsonResponse( + JSON.stringify( + await context.data.prisma.report.findMany({ + select: { + created_at: true, + id: true, + open: true, + target_usernames: true, + }, + where: { + user: { + path: "id", + equals: context.data.current_user.id, + }, + }, + }), + ), + ); }