From e1239bea06358d2ee71d0bf341dc7c7a404aa3c0 Mon Sep 17 00:00:00 2001 From: Chris Hill-Scott Date: Fri, 3 Nov 2017 10:31:28 +0000 Subject: [PATCH] Use model to work out whether to prefix message MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit `service.sms_sender` has been deprecated; we should be looking at which of the service’s SMS senders is default to work out if the message has been sent from GOVUK or not (and if it has, then prefix the message with the service name). The arguments to `SMSMessageTemplate` are _super_ badly named – `sender` isn’t really used as a string, it’s a boolean that effectively means ‘is this a custom sender (`True`) or the platform default (`False`)’. We should rename it once this bug is fixed. --- app/delivery/send_to_providers.py | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/app/delivery/send_to_providers.py b/app/delivery/send_to_providers.py index 324c21582..74316dc08 100644 --- a/app/delivery/send_to_providers.py +++ b/app/delivery/send_to_providers.py @@ -47,11 +47,14 @@ def send_sms_to_provider(notification): "Starting sending SMS {} to provider at {}".format(notification.id, datetime.utcnow()) ) template_model = dao_get_template_by_id(notification.template_id, notification.template_version) + + sender_has_been_customised = (not service.prefix_sms_with_service_name()) + template = SMSMessageTemplate( template_model.__dict__, values=notification.personalisation, prefix=service.name, - sender=service.sms_sender not in {None, current_app.config['FROM_NUMBER']} + sender=sender_has_been_customised, ) if service.research_mode or notification.key_type == KEY_TYPE_TEST: