Skip to content

Commit

Permalink
Browse files Browse the repository at this point in the history
Update game appeal log query
  • Loading branch information
regalijan committed Mar 21, 2024
1 parent 0fb7bf6 commit 1adda19
Showing 1 changed file with 9 additions and 13 deletions.
22 changes: 9 additions & 13 deletions 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 (
Expand Down Expand Up @@ -48,26 +47,23 @@ 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",
};
}

// 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 {
Expand Down

0 comments on commit 1adda19

Please sign in to comment.