feat(infrastructure): use celery worker

This commit is contained in:
2025-10-02 14:59:44 +02:00
parent 9a436d3c70
commit 145565b542
3 changed files with 6 additions and 64 deletions

View File

@@ -1,5 +1,4 @@
import logging
from typing import Any, Dict
from celery import shared_task
@@ -11,34 +10,10 @@ logger.setLevel(logging.INFO)
@shared_task(name="workers.send_email")
def send_email(payload: Dict[str, Any]) -> None:
"""Celery task to send an email.
Expected payload schema:
{
"type": "email",
"to": "recipient@example.com",
"subject": "Subject text",
"body": "Email body text"
}
This mirrors the previous queue worker contract to minimize changes upstream.
"""
to = payload.get("to")
subject = payload.get("subject")
body = payload.get("body")
def send_email(to: str, subject: str, body: str) -> None:
if not (to and subject and body):
logger.error("Email task missing fields. Payload: %s", payload)
logger.error("Email task missing fields. to=%r subject=%r body_len=%r", to, subject, len(body) if body else 0)
return
# Placeholder for real email sending logic
# Implement SMTP provider call here
logger.info("[Celery] Email sent | to=%s | subject=%s | body_len=%d", to, subject, len(body))
@shared_task(name="workers.send_email_fields")
def send_email_fields(to: str, subject: str, body: str) -> None:
"""Alternate signature for convenience when calling from app code.
Routes to the same implementation as send_email.
"""
send_email({"type": "email", "to": to, "subject": subject, "body": body})