diff options
author | Magnus Hagander | 2024-05-14 11:46:20 +0000 |
---|---|---|
committer | Magnus Hagander | 2024-05-14 11:46:20 +0000 |
commit | 3d08134db0fe1c83d38b211ae400e26bede847c9 (patch) | |
tree | 02d7fe667ea9388c38945f83746a989f5a4e2311 /postgresqleu/mailqueue | |
parent | 02db86980bab9c9389f1c2b965615331baba8d6b (diff) |
Complete the sendtime handling for mailqueue
Sync up the "warning button" filtering with that of the alerts, which
means we don̈́'t alert for emails that aren't supposed to be sent yet.
This becomes more relevant as we also stop trying to send emails that
are set to be sent in the future, in preparation for upcoming
functionality to schedule email sending.
Diffstat (limited to 'postgresqleu/mailqueue')
-rw-r--r-- | postgresqleu/mailqueue/backendforms.py | 8 | ||||
-rwxr-xr-x | postgresqleu/mailqueue/management/commands/send_queued_mail.py | 3 |
2 files changed, 10 insertions, 1 deletions
diff --git a/postgresqleu/mailqueue/backendforms.py b/postgresqleu/mailqueue/backendforms.py index 7ccfbdd9..bb79752a 100644 --- a/postgresqleu/mailqueue/backendforms.py +++ b/postgresqleu/mailqueue/backendforms.py @@ -1,4 +1,5 @@ from django import forms +from django.utils import timezone from collections import OrderedDict @@ -40,3 +41,10 @@ class BackendMailqueueForm(BackendForm): self.instance.parsed_msg, self.instance.parsed_txt = parse_mail_content(self.instance.fullmsg) return self.instance.parsed_txt + + @classmethod + def get_rowclass_and_title(self, obj, cache): + if obj.sendtime < timezone.now(): + return "warning", None + else: + return "", None diff --git a/postgresqleu/mailqueue/management/commands/send_queued_mail.py b/postgresqleu/mailqueue/management/commands/send_queued_mail.py index e4fa78ae..d3e36848 100755 --- a/postgresqleu/mailqueue/management/commands/send_queued_mail.py +++ b/postgresqleu/mailqueue/management/commands/send_queued_mail.py @@ -8,6 +8,7 @@ from django.core.management.base import BaseCommand, CommandError from django.db import connection from django.conf import settings +from django.utils import timezone import smtplib @@ -26,7 +27,7 @@ class Command(BaseCommand): if not curs.fetchall()[0][0]: raise CommandError("Failed to get advisory lock, existing send_queued_mail process stuck?") - for m in QueuedMail.objects.all(): + for m in QueuedMail.objects.filter(sendtime__lte=timezone.now()): # Yes, we do a new connection for each run. Just because we can. # If it fails we'll throw an exception and just come back on the # next cron job. And local delivery should never fail... |