clipwright/cloud
juancarlos.cavero 8f873296a1 fix(emails): stop duplicate expiry warnings and fix the button that 404s
Two bugs in the "your N clips will be deleted tomorrow" email.

The button pointed at {frontend_url}/dashboard, a route that has never existed:
the app is a single-page app routed entirely through the hash, and #app is what
opens it. Until today /dashboard fell through to the SPA fallback and quietly
showed the marketing landing, so the link looked like it worked. Now that
unknown paths return a real 404 it fails visibly. Both this and the clips-ready
email now link to /#app; the clips-ready one was passing the bare frontend URL,
which showed the landing page to anyone whose browser had not already set the
skip-landing flag.

The duplicate send is worse. De-duplication was `_warned_video_ids`, a set in
process memory, and the warning window is a full day while the sweep runs every
six hours. Any API restart inside that window re-armed the warning for everyone
already told. That is exactly what happened today: the 06:00 warning went out,
three deploys restarted the API (frontend and API share this repo, so the SEO
pushes redeployed both), the container came up at 12:36, and the sweeper's first
run six hours later at 18:36 mailed the same clips again.

Warnings are now recorded in clip_expiry_warnings, keyed by clip id, written
before the send. A new table rather than a column because the schema bootstrap
is create_all, which creates missing tables but never ALTERs one — same reason
SignupAttribution is its own table. The FK cascades from user_videos, so rows
disappear when purge_free_expired deletes the clip and no cleanup pass is needed.

Recording before sending is deliberate: a duplicate email is the failure being
fixed, while a warning row for a mail that then failed to send costs that user
one notice.

No backfill. Clips already warned about have no row yet, so the current cohort
gets one more warning after this deploys and none after that. Backfilling the
window would also silence the first warning for anyone who entered it since the
last sweep, and a missed deletion notice costs the user their clips, while a
duplicate only costs them an email.

Verified against a real Postgres: create_all builds the table, the primary key
rejects a second row for the same clip, the cascade removes warnings when the
clip is deleted, and warn_free_expiring sends exactly one email across two
sweeps plus a module reload standing in for a restart (which is what used to
produce the second email).
2026-07-27 22:31:04 +02:00
..
__init__.py feat(jobs): reanudar trabajos cortados por un redeploy en vez de perderlos 2026-07-20 22:32:53 +02:00
alerts.py fix(gemini): distinguir bloqueo de contenido de fallo transitorio 2026-07-24 00:37:14 +02:00
auth.py feat(attribution): record where each new account came from 2026-07-27 10:39:24 +02:00
billing.py fix(billing): stop stranding customers whose payment failed 2026-07-25 15:14:15 +02:00
config.py fix(subtitles): stop charging quota for burning captions 2026-07-25 17:16:59 +02:00
database.py feat: add hosted paid mode (managed keys, Stripe trial, metering) 2026-07-14 13:04:43 +02:00
disposable_domains.txt feat(abuse): abrir free a email normal + bloquear dominios desechables 2026-07-21 00:45:54 +02:00
email_policy.py feat(abuse): abrir free a email normal + bloquear dominios desechables 2026-07-21 00:45:54 +02:00
emails.py fix(emails): stop duplicate expiry warnings and fix the button that 404s 2026-07-27 22:31:04 +02:00
LICENSE fix(cloud): harden paid-mode surface + source-available license for cloud/ 2026-07-16 17:30:12 +02:00
managed_keys.py feat: add hosted paid mode (managed keys, Stripe trial, metering) 2026-07-14 13:04:43 +02:00
metering.py fix(billing): stop stranding customers whose payment failed 2026-07-25 15:14:15 +02:00
models.py fix(emails): stop duplicate expiry warnings and fix the button that 404s 2026-07-27 22:31:04 +02:00
oauth.py feat(abuse): abrir free a email normal + bloquear dominios desechables 2026-07-21 00:45:54 +02:00
social_profiles.py feat(social): keep scheduling calendar + add Content calendar button in dashboard 2026-07-16 19:26:51 +02:00
storage.py feat(projects): reopen archived projects from history for further editing 2026-07-18 03:42:17 +02:00
videos.py fix(emails): stop duplicate expiry warnings and fix the button that 404s 2026-07-27 22:31:04 +02:00