From 9c7ed56823a4ba02d9e70f3a9dc4f00c9987add3 Mon Sep 17 00:00:00 2001 From: Joe Carstairs Date: Sat, 24 Jan 2026 10:09:31 +0000 Subject: [PATCH] adds console warn when email exceeds max daily load --- website/src/actions/otp/send-otp.ts | 3 +++ website/src/actions/sendmail.ts | 3 +++ 2 files changed, 6 insertions(+) diff --git a/website/src/actions/otp/send-otp.ts b/website/src/actions/otp/send-otp.ts index 2022990..2781061 100644 --- a/website/src/actions/otp/send-otp.ts +++ b/website/src/actions/otp/send-otp.ts @@ -29,6 +29,9 @@ async function sendOtp({ email, name }: OtpParams) { gte(SentEmails.sentAt, Date.now() - 1000 * 60 * 60 * 24), ); if (emailsSentLast24Hours >= MAX_DAILY_EMAILS) { + console.warn( + `${name} <${email}> requested an OTP, but ${emailsSentLast24Hours} have already been sent, whereas the max daily load is ${MAX_DAILY_EMAILS}.`, + ); throw new Error( `${emailsSentLast24Hours} emails have been sent in the last 24 hours, but the max daily load is ${MAX_DAILY_EMAILS}.`, ); diff --git a/website/src/actions/sendmail.ts b/website/src/actions/sendmail.ts index d68ec95..06bd08a 100644 --- a/website/src/actions/sendmail.ts +++ b/website/src/actions/sendmail.ts @@ -61,6 +61,9 @@ async function sendmail({ gte(SentEmails.sentAt, Date.now() - 1000 * 60 * 60 * 24), ); if (emailsSentLast24Hours > MAX_DAILY_EMAILS) { + console.warn( + `${name} <${email}> tried to send an email, but ${emailsSentLast24Hours} have already been sent, whereas the max daily load is ${MAX_DAILY_EMAILS}.`, + ); throw new Error( `${emailsSentLast24Hours} emails have been sent in the last 24 hours, but the max daily load is ${MAX_DAILY_EMAILS}.`, );