Skip to content

Stop promising an email nobody is sending - #52

Merged
DanialBeg merged 1 commit into
mainfrom
fix/no-unsent-email-promise
Sep 29, 2026
Merged

DanialBeg merged 1 commit into
mainfrom
fix/no-unsent-email-promise

Conversation

@DanialBeg

Copy link
Copy Markdown
Member

The Settings switch defaulted to on, and deadline-digest is a deliberate no-op without EMAIL_PROVIDER_KEY / EMAIL_FROM.

So a student who never opened Settings had been told they would be emailed when a deadline was within a week, and nothing ever was. For a deadline tool that is the one promise most worth keeping, and it was the highest-severity item in the readiness review.

It is off until mail is live.

The bug that would have bitten later

The two sides disagreed about what unset meant:

  • the web app read no stored value as on (DEFAULT_PREFERENCES)
  • the function skipped only an explicit false

Both treat "never touched it" as consent. So the moment a provider key was added, the first cron run would have mailed every student who never opened Settings — people who had been shown a switch already on, but never chose it. The worse version of the original problem: not a promise unkept, but mail nobody asked for.

Both now require an explicit true. Only a deliberate opt-in gets mail.

Turning it on later

  1. Resend account, verify a sender domain (the function posts to api.resend.com/emails)
  2. supabase secrets set EMAIL_PROVIDER_KEY=... EMAIL_FROM=...
  3. POST {"mode":"dry"} to confirm the recipient list looks right before anything sends
  4. Flip DEFAULT_PREFERENCES.email_reminders back to true for new accounts — anyone who already chose keeps their choice

Documented in the function's README.

Testing

485 passing, lint and typecheck clean, and the edge function type-checks under Deno. New tests pin the default off and that a student's own choice is kept either way — the default is exactly the kind of thing that regresses silently.

The settings switch defaulted to on, and the digest function is a deliberate
no-op without EMAIL_PROVIDER_KEY / EMAIL_FROM. So a student who never opened
Settings had been told they would be emailed when a deadline was within a
week, and nothing ever was — the one promise a deadline tool most needs to
keep, and the highest-severity item in the readiness review.

It is off until mail is live.

The two sides also disagreed about what "unset" meant, which would have bitten
at exactly the wrong moment. The web app read no stored value as on; the
function skipped only an explicit false. Adding a provider key would therefore
have mailed every student who never opened Settings — people who had been
shown a switch already on but never chose it. Both now require an explicit
true, so only a deliberate opt-in gets mail.

Flip DEFAULT_PREFERENCES.email_reminders back once a provider is configured;
that governs new accounts, and anyone who already chose keeps their choice.
@cloudflare-workers-and-pages

cloudflare-workers-and-pages Bot commented Sep 28, 2026 •

Copy link
Copy Markdown

Deploying timeline-prototype with  Cloudflare Pages  Cloudflare Pages

Latest commit: 0b37b4b
Status: ✅  Deploy successful!
Preview URL: https://75db297b.timeline-prototype.pages.dev
Branch Preview URL: https://fix-no-unsent-email-promise.timeline-prototype.pages.dev

View logs

@vercel

vercel Bot commented Sep 28, 2026 •

Copy link
Copy Markdown

The latest updates on your projects. Learn more about Vercel for GitHub.

Project Deployment Actions Updated
webapp Ready Ready Preview Sep 28, 2026 3:28am UTC

@DanialBeg
DanialBeg merged commit 2c8c805 into main Sep 29, 2026
5 checks passed
@DanialBeg
DanialBeg deleted the fix/no-unsent-email-promise branch September 29, 2026 04:47

This branch was successfully deployed

1 active deployment
Preview — 0b37b4b1 Deployed Sep 28, 2026 by vercel[bot]
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant