This commit is contained in:
Chris Hill-Scott
2019-11-25 18:02:06 +00:00
parent 3f35c634cd
commit f5f8873a50
5 changed files with 147 additions and 9 deletions

View File

@@ -61,6 +61,13 @@ DELIVERY_STATUS_CALLBACK_TYPE = 'delivery_status'
COMPLAINT_CALLBACK_TYPE = 'complaint'
SERVICE_CALLBACK_TYPES = [DELIVERY_STATUS_CALLBACK_TYPE, COMPLAINT_CALLBACK_TYPE]
EXAMPLE_DOMAINS = (
'@example.com', '@example.net', '@example.org',
'.example.com', '.example.net', '.example.org'
)
OFCOM_PHONE_NUMBER_RANGE = '447700900'
def filter_null_value_fields(obj):
return dict(
@@ -1499,6 +1506,16 @@ class Notification(db.Model):
template_object = get_template_instance(self.template.__dict__, self.personalisation)
return template_object.subject
@property
def dont_send_to_provider(self):
if self.key_type == KEY_TYPE_TEST:
return True
if self.notification_type == EMAIL_TYPE:
return self.normalised_to.endswith(EXAMPLE_DOMAINS)
if self.notification_type == SMS_TYPE:
return self.normalised_to.startswith(OFCOM_PHONE_NUMBER_RANGE)
return False
@property
def formatted_status(self):
return {