Move the mailer out of the mail router so jobs can send too #453
Labels
No labels
Kestra
bug
enhancement
someday
subtask
☁️ api
🎛️ infrastructure
🐞 sentry
📆 2025 Season
📝 pages
allpicks
📝 pages
picks
📝 pages
standings
🚀 performance
No milestone
No project
No assignees
1 participant
Notifications
Due date
No due date set.
Dependencies
No dependencies set
Reference
johnsturgeon/tgfp-web#453
Loading…
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?
Everything needed to send mail lives inside
app/routers/mail.py: theConnectionConfig, theJinja2Templatesinstance,MessageSchemaassembly,and the
FastMailcall. A caller that is not a route cannot reach any of it.app/routers/v2.pyalready importssend_welcome_emailout of the router,which is the shape working against itself -- a router importing from a router
so it can send an email.
Proposed
Move to
app/mailer.py:app/routers/mail.pykeeps its two routes and imports from it.v2.pyimportsfrom
app.mailerinstead ofapp.routers.mail.send_welcome_emailkeeps itsRequest-- it is sent from routes only, andurl_foris the right way to build its links when a request is in hand.Scope
Move only. No new senders, no behaviour change. Adding the picks-page-ready
mail (#209) comes after, and is then a new function plus a job rather than a
refactor tangled with a feature.
Notes for whoever does it
fastapi_mailis async and jobs run in APScheduler's thread pool, so a jobcalling into this will need
asyncio.run(...)at the boundary. Nothing tosolve now, but it is why the module wants to be callable without a request.
email_welcome.j2never uses thediscord_img_urlkey the body passes it.Drop it in the move.