diff --git a/recruitment/tasks.py b/recruitment/tasks.py index 87d2ed4..ceeaad3 100644 --- a/recruitment/tasks.py +++ b/recruitment/tasks.py @@ -1534,7 +1534,6 @@ def send_job_closed_notification(job_id): ) - def send_bulk_email_task( recipient_emails, subject: str, @@ -1559,6 +1558,37 @@ def send_bulk_email_task( context=context, ) + # The return value is stored in the result object for monitoring + return json.dumps({ + "status": "success", + "count": processed_count, + "message": f"Attempted to send email to {len(recipient_emails)} recipients. Service reported processing {processed_count}." + }) + +def send_single_email_task( + recipient_emails, + subject: str, + template_name: str, + context: dict, +) -> str: + """ + Django-Q task to send a bulk email asynchronously. + """ + from .services.email_service import EmailService + + if not recipient_emails: + return json.dumps({"status": "error", "message": "No recipients provided."}) + + service = EmailService() + + # Execute the bulk sending method + processed_count = service.send_bulk_email( + recipient_emails=recipient_emails, + subject=subject, + template_name=template_name, + context=context, + ) + # The return value is stored in the result object for monitoring return json.dumps({ "status": "success",