From da0ce2b18827dbbf5612a5a535cb503bc8cff09e Mon Sep 17 00:00:00 2001 From: Regalijan Date: Sat, 11 Apr 2026 04:54:39 -0400 Subject: [PATCH] Rest of it --- app/routes/appeals.tsx | 16 +++++++++++----- functions/api/me/appeals.ts | 26 +++++++++++++------------- 2 files changed, 24 insertions(+), 18 deletions(-) diff --git a/app/routes/appeals.tsx b/app/routes/appeals.tsx index 5d2fe2d..386a63d 100644 --- a/app/routes/appeals.tsx +++ b/app/routes/appeals.tsx @@ -40,11 +40,17 @@ export async function loader({ context }: { context: RequestContext }) { !Boolean(disabled) && !Boolean(await dataKV.get(`blockedappeal_${currentUser.id}`)) && !Boolean( - await context.env.D1.prepare( - "SELECT * FROM appeals WHERE approved IS NULL AND json_extract(user, '$.id') = ? LIMIT 1;", - ) - .bind(currentUser.id) - .first(), + await context.data.prisma.appeal.findFirst({ + select: { + id: true, + }, + where: { + user: { + path: "id", + equals: currentUser.id, + }, + }, + }), ), can_toggle: currentUser.permissions & (1 << 0) || currentUser.permissions & (1 << 11), diff --git a/functions/api/me/appeals.ts b/functions/api/me/appeals.ts index 162639e..775abf2 100644 --- a/functions/api/me/appeals.ts +++ b/functions/api/me/appeals.ts @@ -1,20 +1,20 @@ -import { jsonError, jsonResponse } from "../../common.js"; +import { jsonResponse } from "../../common.js"; export async function onRequestGet(context: RequestContext) { - const { results, success } = await context.env.D1.prepare( - "SELECT approved, created_at, id, open FROM appeals WHERE user = ?;", - ) - .bind(context.data.current_user.id) - .all(); - - if (!success) return jsonError("Unable to retrieve appeals", 500); - return jsonResponse( JSON.stringify( - results.map((result) => { - result.user = JSON.parse(result.user as string); - - return result; + await context.data.prisma.appeal.findMany({ + select: { + approved: true, + created_at: true, + id: true, + }, + where: { + user: { + path: "id", + equals: context.data.current_user.id, + }, + }, }), ), );