mirror of
https://github.com/GSA/notifications-api.git
synced 2026-08-31 03:34:01 -04:00
WIP
This commit is contained in:
@@ -9,7 +9,7 @@ from notifications_utils.s3 import s3upload
|
||||
|
||||
from app import notify_celery
|
||||
from app.aws.s3 import file_exists
|
||||
from app.models import SMS_TYPE
|
||||
from app.models import EXAMPLE_DOMAINS, OFCOM_PHONE_NUMBER_RANGE, SMS_TYPE
|
||||
from app.config import QueueNames
|
||||
from app.celery.process_ses_receipts_tasks import process_ses_results
|
||||
|
||||
@@ -48,6 +48,8 @@ def send_email_response(reference, to):
|
||||
body = ses_hard_bounce_callback(reference)
|
||||
elif to == temp_fail_email:
|
||||
body = ses_soft_bounce_callback(reference)
|
||||
elif to.lower().endswith(EXAMPLE_DOMAINS):
|
||||
body = ses_hard_bounce_callback(reference)
|
||||
else:
|
||||
body = ses_notification_callback(reference)
|
||||
|
||||
@@ -88,10 +90,14 @@ def mmg_callback(notification_id, to):
|
||||
status: 5 - rejected (perm failure)
|
||||
"""
|
||||
|
||||
if to.strip().endswith(temp_fail):
|
||||
if to.strip().endswith(delivered):
|
||||
status = "3"
|
||||
elif to.strip().endswith(temp_fail):
|
||||
status = "4"
|
||||
elif to.strip().endswith(perm_fail):
|
||||
status = "5"
|
||||
elif to.startswith(OFCOM_PHONE_NUMBER_RANGE):
|
||||
status = "5"
|
||||
else:
|
||||
status = "3"
|
||||
|
||||
@@ -107,10 +113,14 @@ def firetext_callback(notification_id, to):
|
||||
status: 0 - delivered
|
||||
status: 1 - perm failure
|
||||
"""
|
||||
if to.strip().endswith(perm_fail):
|
||||
if to.strip().endswith(delivered):
|
||||
status = "0"
|
||||
elif to.strip().endswith(perm_fail):
|
||||
status = "1"
|
||||
elif to.strip().endswith(temp_fail):
|
||||
status = "2"
|
||||
elif to.startswith(OFCOM_PHONE_NUMBER_RANGE):
|
||||
status = "1"
|
||||
else:
|
||||
status = "0"
|
||||
return {
|
||||
|
||||
@@ -21,7 +21,6 @@ from app.dao.templates_dao import dao_get_template_by_id
|
||||
from app.exceptions import NotificationTechnicalFailureException
|
||||
from app.models import (
|
||||
SMS_TYPE,
|
||||
KEY_TYPE_TEST,
|
||||
BRANDING_BOTH,
|
||||
BRANDING_ORG_BANNER,
|
||||
EMAIL_TYPE,
|
||||
@@ -50,7 +49,7 @@ def send_sms_to_provider(notification):
|
||||
show_prefix=service.prefix_sms,
|
||||
)
|
||||
|
||||
if service.research_mode or notification.key_type == KEY_TYPE_TEST:
|
||||
if service.research_mode or notification.dont_send_to_provider:
|
||||
update_notification_to_sending(notification, provider)
|
||||
send_sms_response(provider.get_name(), str(notification.id), notification.to)
|
||||
|
||||
@@ -96,7 +95,7 @@ def send_email_to_provider(notification):
|
||||
values=notification.personalisation
|
||||
)
|
||||
|
||||
if service.research_mode or notification.key_type == KEY_TYPE_TEST:
|
||||
if service.research_mode or notification.dont_send_to_provider:
|
||||
notification.reference = str(create_uuid())
|
||||
update_notification_to_sending(notification, provider)
|
||||
send_email_response(notification.reference, notification.to)
|
||||
|
||||
@@ -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 {
|
||||
|
||||
Reference in New Issue
Block a user