Description
When a task's due_date is within 24 hours, send the task owner an email reminder. Use FastAPI's built-in BackgroundTasks so it doesn't block the request.
What to do
Acceptance Criteria
- The endpoint returns immediately (does not wait for emails)
- Background tasks fire after the response is returned
- Email credentials are never hardcoded
Hints
from fastapi import BackgroundTasks
@router.post("/send-reminders")
def send_reminders(background_tasks: BackgroundTasks, db: Session = Depends(get_db)):
tasks = get_due_soon(db)
for task in tasks:
background_tasks.add_task(send_reminder_email, task.owner.email, task.title)
return {"queued": len(tasks)}
Difficulty
🔴 Advanced
Description
When a task's
due_dateis within 24 hours, send the task owner an email reminder. Use FastAPI's built-inBackgroundTasksso it doesn't block the request.What to do
notifications.pymodule with asend_reminder_email(to: str, task_title: str)function usingsmtplibor the Resend APIPOST /tasks/send-remindersendpoint (admin-style) that:due_dateis within the next 24 hoursBackgroundTasks{ "queued": N }immediately without waiting for emails to send.env.env.examplefor the required email varsAcceptance Criteria
Hints
Difficulty
🔴 Advanced