adds console warn when email exceeds max daily load

This commit is contained in:
2026-01-24 10:09:31 +00:00
parent 9c9b20a38a
commit 9c7ed56823
2 changed files with 6 additions and 0 deletions

View File

@@ -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}.`,
);