Add support for staggering outgoing emails

Sent email can be assigned a "stagger type", for which he system will
maintain a "last sent" information. When the email is sent, it will be
delayed to be at least "stagger" time after the last one sent of the
same type. If no email of this type has been sent before, the email is
of course sent immediately.
This commit is contained in:
Magnus Hagander
2020-10-29 15:27:56 +01:00
parent 25180ee829
commit adf5eb2a34
5 changed files with 59 additions and 10 deletions

View File

@ -10,6 +10,12 @@ class QueuedMail(models.Model):
# Flag if the message is "user generated", so we can treat those
# separately from an antispam and delivery perspective.
usergenerated = models.BooleanField(null=False, blank=False, default=False)
sendat = models.DateTimeField(null=False, blank=False)
def __str__(self):
return "%s: %s -> %s" % (self.pk, self.sender, self.receiver)
class LastSent(models.Model):
type = models.CharField(max_length=10, null=False, blank=False, unique=True)
lastsent = models.DateTimeField(null=False, blank=False)