Use model to work out whether to prefix message

`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.
This commit is contained in:
Chris Hill-Scott
2017-11-03 10:31:28 +00:00
parent 92b605833f
commit e1239bea06

View File

@@ -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: