remove celery

This commit is contained in:
2025-06-04 08:33:04 +02:00
parent ea841e4d54
commit 8edd96b671
6 changed files with 19 additions and 140 deletions

View File

@@ -10,7 +10,6 @@ from email.mime.text import MIMEText
from email.mime.multipart import MIMEMultipart
from email.utils import formatdate
import json
from celery_worker import celery
logger = logging.getLogger(__name__)
@@ -31,16 +30,9 @@ def get_smtp_settings() -> Optional[Dict[str, Any]]:
logger.error(f"Error retrieving SMTP settings: {str(e)}")
return None
@celery.task
def send_email_task(mail_id: int):
"""Celery task to send an email asynchronously"""
def send_email_via_smtp(mail: Mail) -> bool:
"""Send an email synchronously"""
try:
# Get the mail record
mail = Mail.query.get(mail_id)
if not mail:
logger.error(f"Mail record not found for ID: {mail_id}")
return False
# Get SMTP settings
smtp_settings = get_smtp_settings()
if not smtp_settings:
@@ -76,20 +68,6 @@ def send_email_task(mail_id: int):
except Exception as e:
logger.error(f"Error sending email: {str(e)}")
if mail:
mail.status = 'failed'
mail.error_message = str(e)
db.session.commit()
return False
def send_email_via_smtp(mail: Mail) -> bool:
"""Queue an email to be sent asynchronously"""
try:
# Queue the email sending task
send_email_task.delay(mail.id)
return True
except Exception as e:
logger.error(f"Error queueing email: {str(e)}")
mail.status = 'failed'
mail.error_message = str(e)
db.session.commit()