This commit is contained in:
Regalijan 2023-11-01 09:03:46 -04:00
parent c124aa245e
commit e40eb9ecfc
Signed by: regalijan
GPG Key ID: 5D4196DA269EF520

View File

@ -23,13 +23,13 @@ export async function onRequestPost(context: RequestContext) {
if (reasonForUnban.length > 5000 || whatHappened.length > 5000) if (reasonForUnban.length > 5000 || whatHappened.length > 5000)
return jsonError( return jsonError(
"The maximum length of each text field is 5000 characters", "The maximum length of each text field is 5000 characters",
400 400,
); );
if (reasonForUnban.length < 100) if (reasonForUnban.length < 100)
return jsonError( return jsonError(
"Your explanation of why you should be unbanned must be longer", "Your explanation of why you should be unbanned must be longer",
400 400,
); );
if (whatHappened.length < 50) if (whatHappened.length < 50)
@ -54,13 +54,15 @@ export async function onRequestPost(context: RequestContext) {
reasonForUnban, reasonForUnban,
roblox_id: id, roblox_id: id,
roblox_username: username, roblox_username: username,
whatHappened whatHappened,
}) }),
); );
await context.env.D1.prepare( await context.env.D1.prepare(
"INSERT INTO game_appeals (created_at, id, open, user) VALUES (?, ?, ?, ?);" "INSERT INTO game_appeals (created_at, id, open, user) VALUES (?, ?, ?, ?);",
).bind(Date.now(), appealId, 1, id); )
.bind(Date.now(), appealId, 1, id)
.run();
await fetch(context.env.REPORTS_WEBHOOK, { await fetch(context.env.REPORTS_WEBHOOK, {
body: JSON.stringify({ body: JSON.stringify({
@ -68,17 +70,17 @@ export async function onRequestPost(context: RequestContext) {
{ {
color: 3756250, color: 3756250,
description: `${username} has pleaded for forgiveness! Head to https://carcrushers.cc/mod-queue?id=${appealId}&type=gma`, description: `${username} has pleaded for forgiveness! Head to https://carcrushers.cc/mod-queue?id=${appealId}&type=gma`,
title: "Appeal Submitted" title: "Appeal Submitted",
} },
] ],
}), }),
headers: { headers: {
"content-type": "application/json" "content-type": "application/json",
}, },
method: "POST" method: "POST",
}); });
return new Response(null, { return new Response(null, {
status: 204 status: 204,
}); });
} }