Phase 2b: Scheduled send — send_at + CronJob worker #5
Loading…
Add table
Add a link
Reference in a new issue
No description provided.
Delete branch "%!s()"
Deleting a branch is permanent. Although the deleted branch may continue to exist for a short time before it actually gets removed, it CANNOT be undone in most cases. Continue?
Type
Feature
Lineage
plan-pal-e-mail→ Phase 2bRepo
forgejo_admin/pal-e-mailUser Story
As a platform admin (Lucas)
I want to schedule an email for future delivery via POST /send with a send_at field
So that I can prepare emails now and have them delivered at the right time without manual intervention
Context
Phase 2 delivers immediate send only. Lucas needs to schedule emails for specific dates (e.g., jersey reminders for next Tuesday). The send_at field on POST /send queues instead of sending immediately. A k8s CronJob polls the scheduled_emails table every minute and sends due emails. Apps resolve their own recipients and timing — pal-e-mail just handles queued delivery.
File Targets
Files to create:
src/pal_e_mail/models.py— add ScheduledEmail model (sender, to, subject, project, template, html, data, brand_name, send_at, status, created_at)src/pal_e_mail/routes/scheduled.py— GET /scheduled (list pending), DELETE /scheduled/{id} (cancel)src/pal_e_mail/services/scheduler.py— send_due_emails() function, called by workeralembic/versions/002_scheduled_emails.py— migration for scheduled_emails tableFiles to modify:
src/pal_e_mail/schemas.py— add send_at: datetime | None to SendRequest, add ScheduledEntry/ScheduledResponse modelssrc/pal_e_mail/routes/send.py— if send_at provided, queue instead of sendsrc/pal_e_mail/main.py— include scheduled routerInfrastructure:
Acceptance Criteria
Test Expectations
cd ~/pal-e-mail && .venv/bin/pytest tests/ -vConstraints
Checklist
Related
project-pal-e-mail— parent projectplan-pal-e-mail— parent plan Phase 2bforgejo_admin/pal-e-mail#3— Phase 2 (predecessor)