Prefix all SMS messages with service name

Implements https://github.com/alphagov/notifications-utils/pull/4
This commit is contained in:
Chris Hill-Scott
2016-03-01 08:48:27 +00:00
parent fa4b2e16e7
commit 0e5d72494e
3 changed files with 13 additions and 7 deletions

View File

@@ -2,6 +2,7 @@ from app import create_uuid
from app import notify_celery, encryption, firetext_client, aws_ses_client
from app.clients.email.aws_ses import AwsSesClientException
from app.clients.sms.firetext import FiretextClientException
from app.dao.services_dao import dao_fetch_service_by_id
from app.dao.templates_dao import dao_get_template_by_id
from app.dao.notifications_dao import dao_create_notification, dao_update_notification
from app.dao.jobs_dao import dao_update_job, dao_get_job_by_id
@@ -64,9 +65,11 @@ def process_job(job_id):
@notify_celery.task(name="send-sms")
def send_sms(service_id, notification_id, encrypted_notification, created_at):
notification = encryption.decrypt(encrypted_notification)
service = dao_fetch_service_by_id(service_id)
template = Template(
dao_get_template_by_id(notification['template']),
values=notification.get('personalisation', {})
dao_get_template_by_id(notification['template']).__dict__,
values=notification.get('personalisation', {}),
prefix=service.name
)
client = firetext_client
@@ -107,7 +110,7 @@ def send_sms(service_id, notification_id, encrypted_notification, created_at):
def send_email(service_id, notification_id, subject, from_address, encrypted_notification, created_at):
notification = encryption.decrypt(encrypted_notification)
template = Template(
dao_get_template_by_id(notification['template']),
dao_get_template_by_id(notification['template']).__dict__,
values=notification.get('personalisation', {})
)