mirror of
https://github.com/GSA/notifications-admin.git
synced 2026-08-18 21:49:37 -04:00
Merge pull request #1614 from alphagov/fix-escaped-characters-inbound
Stop escaping special characters in inbound messages
This commit is contained in:
@@ -10,7 +10,7 @@ from notifications_utils.recipients import format_phone_number_human_readable
|
||||
from notifications_utils.template import SMSPreviewTemplate
|
||||
from app.main import main
|
||||
from app.main.forms import SearchTemplatesForm
|
||||
from app.utils import user_has_permissions
|
||||
from app.utils import user_has_permissions, unescape_string
|
||||
from app import notification_api_client, service_api_client
|
||||
from notifications_python_client.errors import HTTPError
|
||||
|
||||
@@ -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 (
|
||||
unescape_string(notification['content']) if is_inbound else
|
||||
notification['template']['content']
|
||||
)
|
||||
|
||||
@@ -31,6 +31,7 @@ from app.utils import (
|
||||
FAILURE_STATUSES,
|
||||
REQUESTED_STATUSES,
|
||||
Spreadsheet,
|
||||
unescape_string,
|
||||
)
|
||||
|
||||
|
||||
@@ -203,6 +204,9 @@ def get_inbox_partials(service_id):
|
||||
format_phone_number_human_readable(message['user_number'])
|
||||
for message in messages_to_show
|
||||
}:
|
||||
message.update({
|
||||
'content': unescape_string(message['content'])
|
||||
})
|
||||
messages_to_show.append(message)
|
||||
|
||||
if not inbound_messages:
|
||||
|
||||
Reference in New Issue
Block a user