From cc79d29c8e98a0497e86df398226966b01be2bfb Mon Sep 17 00:00:00 2001 From: Regalijan Date: Tue, 2 Jun 2026 18:15:05 -0400 Subject: [PATCH 1/5] Fix time nonsense with new et striked --- functions/api/events-team/strikes/new.ts | 5 ++--- 1 file changed, 2 insertions(+), 3 deletions(-) diff --git a/functions/api/events-team/strikes/new.ts b/functions/api/events-team/strikes/new.ts index 417b661..dc98e8d 100644 --- a/functions/api/events-team/strikes/new.ts +++ b/functions/api/events-team/strikes/new.ts @@ -19,14 +19,13 @@ export async function onRequestPost(context: RequestContext) { ) return jsonError("Invalid user id", 400); - const now = Date.now(); const id = crypto.randomUUID().replaceAll("-", ""); const actingUser = context.data.current_user.id; await D1.batch([ D1.prepare( - "INSERT INTO et_strikes (created_at, created_by, id, reason, user) VALUES (?, ?, ?, ?, ?);", - ).bind(now, actingUser, id, reason, user), + "INSERT INTO et_strikes (created_by, id, reason, user) VALUES (?, ?, ?, ?);", + ).bind(actingUser, id, reason, user), D1.prepare( "UPDATE et_members SET points = points - 100 WHERE id = ?;", ).bind(user), From a76749bfff5e28c6cbc92c310306d2125b4aae04 Mon Sep 17 00:00:00 2001 From: Regalijan Date: Tue, 2 Jun 2026 18:25:34 -0400 Subject: [PATCH 2/5] Prevent more than three events pre-bookings --- app/routes/book-event.tsx | 30 +++++++++++++++++++++++++++--- 1 file changed, 27 insertions(+), 3 deletions(-) diff --git a/app/routes/book-event.tsx b/app/routes/book-event.tsx index 3bd7f41..d7b3b4a 100644 --- a/app/routes/book-event.tsx +++ b/app/routes/book-event.tsx @@ -1,4 +1,8 @@ import { + Alert, + AlertDescription, + AlertIcon, + AlertTitle, Button, Container, Heading, @@ -28,11 +32,23 @@ export async function loader({ context }: { context: RequestContext }) { status: 403, }); - return null; + const now = new Date(); + const preBookedEvents = await context.data.prisma.event.count({ + where: { + created_by: context.data.current_user.id, + day: { + gte: now.getUTCDate(), + }, + month: now.getUTCMonth() + 1, + year: now.getUTCFullYear(), + }, + }); + + return preBookedEvents > 3; } export default function () { - useLoaderData(); + const exceededMaxBookings = useLoaderData(); const toast = useToast(); const currentDate = new Date(); @@ -44,7 +60,7 @@ export default function () { const [eventType, setEventType] = useState(""); const [riddleAnswer, setRiddleAnswer] = useState(""); const [submitSuccess, setSubmitSuccess] = useState(false); - const [disableSubmit, setDisableSubmit] = useState(false); + const [disableSubmit, setDisableSubmit] = useState(exceededMaxBookings); useEffect(() => { setDatePickerMin(`${new Date().toISOString().split("T").at(0)}`); @@ -112,6 +128,14 @@ export default function () { /> ) : ( + + + Max pre-bookings exceeded! + + You cannot pre-book more than three events. Please wait until you + complete an event before trying again. + + Book an Event Event Type From 3ee4a6cb29f87171bef141b7a9cffa235ca9f177 Mon Sep 17 00:00:00 2001 From: Regalijan Date: Tue, 2 Jun 2026 18:27:18 -0400 Subject: [PATCH 3/5] Fix et report formatting --- app/routes/events-team_.report.tsx | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/app/routes/events-team_.report.tsx b/app/routes/events-team_.report.tsx index a285fe4..cdc4437 100644 --- a/app/routes/events-team_.report.tsx +++ b/app/routes/events-team_.report.tsx @@ -136,11 +136,11 @@ export default function () { my="16px" onClick={async () => { await navigator.clipboard.writeText( - `local Report = { + `\`\`\`\nlocal Report = { ${Object.values(data.members) .map((v) => `[${v.roblox_id}] = ${v.points};`) .join("\n ")} -}`, +}\n\`\`\``, ); alert("Report copied."); From 2ae11670deaa3df0edfa7fbe279a568a150ce80b Mon Sep 17 00:00:00 2001 From: Regalijan Date: Tue, 2 Jun 2026 18:31:28 -0400 Subject: [PATCH 4/5] Enforce event booking limit server side --- functions/api/events-team/events/new.ts | 22 +++++++++++++++++++--- 1 file changed, 19 insertions(+), 3 deletions(-) diff --git a/functions/api/events-team/events/new.ts b/functions/api/events-team/events/new.ts index a5e689a..4742aaf 100644 --- a/functions/api/events-team/events/new.ts +++ b/functions/api/events-team/events/new.ts @@ -21,8 +21,24 @@ export async function onRequestPost(context: RequestContext) { ) return jsonError("Invalid body", 400); + const { prisma } = context.data; + if ( - await context.data.prisma.event.findFirst({ + (await prisma.event.count({ + where: { + created_by: context.data.current_user.id, + day: { + gte: now.getUTCDate(), + }, + month: currentMonth, + year: currentYear, + }, + })) > 3 + ) + return jsonError("Too many events scheduled", 403); + + if ( + await prisma.event.findFirst({ select: { id: true, }, @@ -51,7 +67,7 @@ export async function onRequestPost(context: RequestContext) { const weekRange = Math.floor(day / 7); - const existingEventInRange = await context.data.prisma.event.findFirst({ + const existingEventInRange = await prisma.event.findFirst({ select: { id: true, }, @@ -73,7 +89,7 @@ export async function onRequestPost(context: RequestContext) { const id = `${now.getTime()}${crypto.randomUUID().replaceAll("-", "")}`; - await context.data.prisma.event.create({ + await prisma.event.create({ data: { answer: context.data.body.answer || null, approved: type === "gamenight", From 472299d4f5a780304eee4f2b80814c043499b3d5 Mon Sep 17 00:00:00 2001 From: Regalijan Date: Tue, 2 Jun 2026 18:42:19 -0400 Subject: [PATCH 5/5] Fix math --- app/routes/book-event.tsx | 2 +- functions/api/events-team/events/new.ts | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/app/routes/book-event.tsx b/app/routes/book-event.tsx index d7b3b4a..828cdae 100644 --- a/app/routes/book-event.tsx +++ b/app/routes/book-event.tsx @@ -44,7 +44,7 @@ export async function loader({ context }: { context: RequestContext }) { }, }); - return preBookedEvents > 3; + return preBookedEvents >= 3; } export default function () { diff --git a/functions/api/events-team/events/new.ts b/functions/api/events-team/events/new.ts index 4742aaf..48b7b9c 100644 --- a/functions/api/events-team/events/new.ts +++ b/functions/api/events-team/events/new.ts @@ -33,7 +33,7 @@ export async function onRequestPost(context: RequestContext) { month: currentMonth, year: currentYear, }, - })) > 3 + })) >= 3 ) return jsonError("Too many events scheduled", 403);