Merge pull request #1516 from alphagov/empty-inbound-sms

make sure inbound sms page doesn't break if you receive a blank inbou…
This commit is contained in:
Leo Hemsted
2017-09-29 13:51:30 +01:00
committed by GitHub
4 changed files with 52 additions and 20 deletions

View File

@@ -107,7 +107,7 @@ class Development(Config):
class Test(Development):
DEBUG = True
TESTING = True
STATSD_ENABLED = True
STATSD_ENABLED = False
WTF_CSRF_ENABLED = False
CSV_UPLOAD_BUCKET_NAME = 'test-notifications-csv-upload'
LOGO_UPLOAD_BUCKET_NAME = 'public-logos-test'

View File

@@ -64,7 +64,7 @@ def get_sms_thread(service_id, user_number):
), key=lambda notification: notification['created_at']):
is_inbound = ('notify_number' in notification)
redact_personalisation = notification.get('template', {}).get('redact_personalisation', False)
redact_personalisation = not is_inbound and notification['template']['redact_personalisation']
if redact_personalisation:
notification['personalisation'] = {}
@@ -73,7 +73,10 @@ def get_sms_thread(service_id, user_number):
'inbound': is_inbound,
'content': SMSPreviewTemplate(
{
'content': notification.get('content') or notification['template']['content']
'content': (
notification['content'] if is_inbound else
notification['template']['content']
)
},
notification.get('personalisation'),
downgrade_non_gsm_characters=(not is_inbound),