mirror of
https://github.com/GSA/notifications-admin.git
synced 2026-08-25 00:33:58 -04:00
Factor out string escaping code
So that it only lives in one place.
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 notifications_utils.template import SMSPreviewTemplate
|
||||||
from app.main import main
|
from app.main import main
|
||||||
from app.main.forms import SearchTemplatesForm
|
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 app import notification_api_client, service_api_client
|
||||||
from notifications_python_client.errors import HTTPError
|
from notifications_python_client.errors import HTTPError
|
||||||
|
|
||||||
@@ -133,6 +133,6 @@ def get_sms_thread(service_id, user_number):
|
|||||||
|
|
||||||
def get_sms_content(notification, is_inbound):
|
def get_sms_content(notification, is_inbound):
|
||||||
return (
|
return (
|
||||||
bytes(notification['content'], "utf-8").decode('unicode_escape') if is_inbound else
|
unescape_string(notification['content']) if is_inbound else
|
||||||
notification['template']['content']
|
notification['template']['content']
|
||||||
)
|
)
|
||||||
|
|||||||
@@ -31,6 +31,7 @@ from app.utils import (
|
|||||||
FAILURE_STATUSES,
|
FAILURE_STATUSES,
|
||||||
REQUESTED_STATUSES,
|
REQUESTED_STATUSES,
|
||||||
Spreadsheet,
|
Spreadsheet,
|
||||||
|
unescape_string,
|
||||||
)
|
)
|
||||||
|
|
||||||
|
|
||||||
@@ -204,7 +205,7 @@ def get_inbox_partials(service_id):
|
|||||||
for message in messages_to_show
|
for message in messages_to_show
|
||||||
}:
|
}:
|
||||||
message.update({
|
message.update({
|
||||||
'content': bytes(message['content'], 'utf-8').decode('unicode_escape')
|
'content': unescape_string(message['content'])
|
||||||
})
|
})
|
||||||
messages_to_show.append(message)
|
messages_to_show.append(message)
|
||||||
|
|
||||||
|
|||||||
@@ -379,3 +379,7 @@ def get_cdn_domain():
|
|||||||
domain = parsed_uri.netloc[len(subdomain + '.'):]
|
domain = parsed_uri.netloc[len(subdomain + '.'):]
|
||||||
|
|
||||||
return "static-logos.{}".format(domain)
|
return "static-logos.{}".format(domain)
|
||||||
|
|
||||||
|
|
||||||
|
def unescape_string(string):
|
||||||
|
return bytes(string, "utf-8").decode('unicode_escape')
|
||||||
|
|||||||
Reference in New Issue
Block a user