Factor out code that gets message content

The nesting is getting pretty deep here. Let’s make it into its own
method so it doesn’t get out of hand when we add more functionality to
it.
This commit is contained in:
Chris Hill-Scott
2017-11-06 12:15:26 +00:00
parent db8f7032fe
commit fed4275403

View File

@@ -120,12 +120,7 @@ def get_sms_thread(service_id, user_number):
yield {
'inbound': is_inbound,
'content': SMSPreviewTemplate(
{
'content': (
notification['content'] if is_inbound else
notification['template']['content']
)
},
{'content': get_sms_content(notification, is_inbound)},
notification.get('personalisation'),
downgrade_non_gsm_characters=(not is_inbound),
redact_missing_personalisation=redact_personalisation,
@@ -134,3 +129,10 @@ def get_sms_thread(service_id, user_number):
'status': notification.get('status'),
'id': notification['id'],
}
def get_sms_content(notification, is_inbound):
return (
notification['content'] if is_inbound else
notification['template']['content']
)