From 1adda195f0fc1245d52c3ec3c4bdb5dada99c718 Mon Sep 17 00:00:00 2001 From: Regalijan Date: Thu, 21 Mar 2024 13:46:03 -0400 Subject: [PATCH] Update game appeal log query --- functions/api/game-appeals/precheck.ts | 22 +++++++++------------- 1 file changed, 9 insertions(+), 13 deletions(-) diff --git a/functions/api/game-appeals/precheck.ts b/functions/api/game-appeals/precheck.ts index 8b50b98..fe1a306 100644 --- a/functions/api/game-appeals/precheck.ts +++ b/functions/api/game-appeals/precheck.ts @@ -1,4 +1,3 @@ -import { queryLogs } from "../../gcloud.js"; import { getBanList } from "../../roblox-open-cloud.js"; export default async function ( @@ -48,7 +47,13 @@ export default async function ( let userLogs; try { - userLogs = await queryLogs(user, context); + userLogs = await context.env.D1.prepare( + "SELECT executed_at FROM game_mod_logs WHERE target = ? ORDER bv executed_at DESC;", + ) + .bind(user) + .all(); + + if (userLogs.error) throw new Error("Query failed"); } catch { return { error: "Could not determine your eligibility", @@ -56,18 +61,9 @@ export default async function ( } // Legacy bans - if (!userLogs.length) return { can_appeal: true, reason: "" }; - - userLogs.sort((a, b) => - parseInt(a.entity.properties.executed_at.integerValue) > - parseInt(b.entity.properties.executed_at.integerValue) - ? -1 - : 1, - ); + if (!userLogs.results.length) return { can_appeal: true, reason: "" }; - const allowedTime = - parseInt(userLogs[0].entity.properties.executed_at.integerValue) + - 2592000000; + const allowedTime = (userLogs.results[0].executed_at as number) + 2592000000; if (Date.now() < allowedTime) return {