Get the sms sender from the notificaiton_sms_sender mapping table if that does not exist get the default sms sender to pass on to the sms provider.

This commit is contained in:
Rebecca Law
2017-10-30 14:55:44 +00:00
parent 4eec11b633
commit 0887910b1b
5 changed files with 69 additions and 9 deletions

View File

@@ -11,8 +11,8 @@ from notifications_utils.template import HTMLEmailTemplate, PlainTextEmailTempla
from app import clients, statsd_client, create_uuid
from app.dao.notifications_dao import (
dao_update_notification,
dao_get_notification_email_reply_for_notification
)
dao_get_notification_email_reply_for_notification,
dao_get_notification_sms_sender_mapping)
from app.dao.provider_details_dao import (
get_provider_details_by_notification_type,
dao_toggle_sms_provider
@@ -69,11 +69,15 @@ def send_sms_to_provider(notification):
raise
else:
try:
sms_sender = dao_get_notification_sms_sender_mapping(notification.id)
if not sms_sender:
sms_sender = service.get_default_sms_sender()
provider.send_sms(
to=validate_and_format_phone_number(notification.to, international=notification.international),
content=str(template),
reference=str(notification.id),
sender=service.get_default_sms_sender()
sender=sms_sender
)
except Exception as e:
dao_toggle_sms_provider(provider.name)