mirror of
https://github.com/GSA/notifications-api.git
synced 2026-08-24 00:06:16 -04:00
ensure emails are formatted before sending
we allow some invalid to addresses - for example, phone numbers with spaces or brackets - in the database. This is so that users can match up their data in a format that they expect (since they passed it in). When we send SMS, we strip this formatting just before sending - but we weren't with email. This commit changes that and adds some tests. It also adds formatting for reply_to addresses. We should never expect invalid reply_to email addresses in our data, but just in case, lets validate them here. Also, bump requirements.txt to capture some more email validation
This commit is contained in:
@@ -109,7 +109,7 @@ def create_notification(
|
||||
template,
|
||||
job=None,
|
||||
job_row_number=None,
|
||||
to_field='+447700900855',
|
||||
to_field=None,
|
||||
status='created',
|
||||
reference=None,
|
||||
created_at=None,
|
||||
@@ -131,6 +131,9 @@ def create_notification(
|
||||
if created_at is None:
|
||||
created_at = datetime.utcnow()
|
||||
|
||||
if to_field is None:
|
||||
to_field = '+447700900855' if template.template_type == SMS_TYPE else 'test@example.com'
|
||||
|
||||
if status != 'created':
|
||||
sent_at = sent_at or datetime.utcnow()
|
||||
updated_at = updated_at or datetime.utcnow()
|
||||
|
||||
Reference in New Issue
Block a user