diff --git a/app/main/views/conversation.py b/app/main/views/conversation.py index 783e244fd..ffbda324f 100644 --- a/app/main/views/conversation.py +++ b/app/main/views/conversation.py @@ -33,23 +33,23 @@ def get_user_number(service_id, notification_id): def get_sms_thread(service_id, user_number): - return [ - { - 'inbound': ('notify_number' in notification), + + for notification in sorted(( + notification_api_client.get_notifications_for_service(service_id, to=user_number)['notifications'] + + service_api_client.get_inbound_sms(service_id, user_number=user_number) + ), key=lambda notification: notification['created_at']): + + is_inbound = ('notify_number' in notification) + + yield { + 'inbound': is_inbound, 'content': SMSPreviewTemplate( { 'content': notification.get('content') or notification['template']['content'] - } + }, + downgrade_non_gsm_characters=(not is_inbound) ), 'created_at': notification['created_at'], 'status': notification.get('status'), 'id': notification['id'], } - for notification in sorted( - ( - notification_api_client.get_notifications_for_service(service_id, to=user_number)['notifications'] + - service_api_client.get_inbound_sms(service_id, user_number=user_number) - ), - key=lambda notification: notification['created_at'], - ) - ] diff --git a/requirements.txt b/requirements.txt index 03158b9fd..ff93059fc 100644 --- a/requirements.txt +++ b/requirements.txt @@ -28,4 +28,4 @@ notifications-python-client>=3.1,<3.2 awscli>=1.11,<1.12 awscli-cwlogs>=1.4,<1.5 -git+https://github.com/alphagov/notifications-utils.git@17.2.0#egg=notifications-utils==17.2.0 +git+https://github.com/alphagov/notifications-utils.git@17.3.0#egg=notifications-utils==17.3.0 diff --git a/tests/app/main/views/test_conversation.py b/tests/app/main/views/test_conversation.py index a9ad71369..26f845b19 100644 --- a/tests/app/main/views/test_conversation.py +++ b/tests/app/main/views/test_conversation.py @@ -76,8 +76,6 @@ def test_view_conversation( expected, ): - print(index) - response = logged_in_client.get(url_for( 'main.conversation', service_id=SERVICE_ONE_ID, @@ -89,9 +87,8 @@ def test_view_conversation( messages = page.select('.sms-message-wrapper') statuses = page.select('.sms-message-status') - for elements in (messages, statuses): - assert len(elements) == 13 - + assert len(messages) == 13 + assert len(statuses) == 13 assert ( normalize_spaces(messages[index].text), normalize_spaces(statuses[index].text),