* test: Test rfc_editor_index_update_task * chore: Add docstring to test * fix: Reuse stats instead of fetching twice * test: Test fetch_meeting_attendance_task * chore: Remove outdated tasks * Revert "chore: Add docstring to test" This reverts commit 0395410d665c0d310248fd151386f013357c5d13. * Revert "test: Test rfc_editor_index_update_task" This reverts commit 4dd9dd131723497db3d2aa76166169fd32c42fdd. * test: Test rfc_editor_index_update_task This time without reformatting the entire file... * chore: Remove accidentally committed fragment * test: Annotate function to satisfy mypy * chore: Remove unused imports
28 lines
911 B
Python
28 lines
911 B
Python
# Copyright The IETF Trust 2024 All Rights Reserved
|
|
#
|
|
# Celery task definitions
|
|
#
|
|
from celery import shared_task
|
|
from smtplib import SMTPException
|
|
|
|
from ietf.message.utils import send_scheduled_message_from_send_queue
|
|
from ietf.message.models import SendQueue
|
|
from ietf.utils import log
|
|
from ietf.utils.mail import log_smtp_exception, send_error_email
|
|
|
|
|
|
@shared_task
|
|
def send_scheduled_mail_task():
|
|
"""Send scheduled email
|
|
|
|
This is equivalent to `ietf/bin/send-scheduled-mail all`, which was the only form used in the cron job.
|
|
"""
|
|
needs_sending = SendQueue.objects.filter(sent_at=None).select_related("message")
|
|
for s in needs_sending:
|
|
try:
|
|
send_scheduled_message_from_send_queue(s)
|
|
log.log('Sent scheduled message %s "%s"' % (s.id, s.message.subject))
|
|
except SMTPException as e:
|
|
log_smtp_exception(e)
|
|
send_error_email(e)
|