Skip to content

Commit

Permalink
Ensure sent email always has sent_at (#302)
Browse files Browse the repository at this point in the history
  • Loading branch information
c-w authored Jan 30, 2020
1 parent b3c30e4 commit 78ff0e5
Showing 1 changed file with 4 additions and 0 deletions.
4 changes: 4 additions & 0 deletions opwen_email_server/integration/webapp.py
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
from datetime import datetime
from typing import Callable
from typing import Dict
from typing import Iterable
Expand Down Expand Up @@ -149,6 +150,9 @@ def _create(self, emails_or_attachments: Iterable[dict]):
if email.get('_type') == 'attachment':
raise NotImplementedError

if not email.get('sent_at'):
email['sent_at'] = datetime.utcnow().strftime('%Y-%m-%d %H:%M')

email_id = email['_uid']
self._email_storage.store_object(email_id, email)
self._send_email(email_id)
Expand Down

0 comments on commit 78ff0e5

Please sign in to comment.