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

@@ -44,7 +44,9 @@ from app.models import (
NOTIFICATION_TEMPORARY_FAILURE,
NOTIFICATION_PERMANENT_FAILURE,
NOTIFICATION_SENT,
NotificationSmsSender)
NotificationSmsSender,
ServiceSmsSender
)
from app.dao.dao_utils import transactional
from app.statsd_decorators import statsd
@@ -659,3 +661,14 @@ def dao_create_notification_sms_sender_mapping(notification_id, sms_sender_id):
service_sms_sender_id=sms_sender_id
)
db.session.add(notification_to_sms_sender)
def dao_get_notification_sms_sender_mapping(notification_id):
sms_sender = ServiceSmsSender.query.join(
NotificationSmsSender
).filter(
NotificationSmsSender.notification_id == notification_id
).first()
if sms_sender:
return sms_sender.sms_sender