Skip to content

Commit

Permalink
🤝 add sent_at field (#38)
Browse files Browse the repository at this point in the history
  • Loading branch information
joshuadavidthomas authored Sep 28, 2023
1 parent fb00700 commit e216277
Show file tree
Hide file tree
Showing 2 changed files with 5 additions and 1 deletion.
3 changes: 2 additions & 1 deletion src/email_relay/migrations/0001_initial.py
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
# Generated by Django 4.2.5 on 2023-09-27 12:20
# Generated by Django 4.2.5 on 2023-09-27 18:38

from django.db import migrations, models

Expand Down Expand Up @@ -50,6 +50,7 @@ class Migration(migrations.Migration):
),
("created_at", models.DateTimeField(auto_now_add=True)),
("updated_at", models.DateTimeField(auto_now=True)),
("sent_at", models.DateTimeField(blank=True, null=True)),
],
options={
"ordering": ["created_at"],
Expand Down
3 changes: 3 additions & 0 deletions src/email_relay/models.py
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@
from django.core.mail import EmailMessage
from django.core.mail import EmailMultiAlternatives
from django.db import models
from django.utils import timezone


class Priority(models.IntegerChoices):
Expand Down Expand Up @@ -65,6 +66,7 @@ class Message(models.Model):

created_at = models.DateTimeField(auto_now_add=True, editable=False)
updated_at = models.DateTimeField(auto_now=True, editable=False)
sent_at = models.DateTimeField(null=True, blank=True)

objects = MessageQuerySet.as_manager()

Expand All @@ -89,6 +91,7 @@ def save(self, *args, **kwargs):

def mark_sent(self):
self.status = Status.SENT
self.sent_at = timezone.now()
self.save()

def defer(self, log: str = ""):
Expand Down

0 comments on commit e216277

Please sign in to comment.