merge from main

This commit is contained in:
Kenneth Kehl
2024-06-06 13:18:00 -07:00
parent feb8a1bfaf
commit 6081ff4873
3 changed files with 17 additions and 6 deletions

View File

@@ -25,7 +25,6 @@ from app.notifications.validators import check_service_over_total_message_limit
from app.serialised_models import SerialisedService, SerialisedTemplate from app.serialised_models import SerialisedService, SerialisedTemplate
from app.service.utils import service_allowed_to_send_to from app.service.utils import service_allowed_to_send_to
from app.utils import DATETIME_FORMAT, hilite, scrub, utc_now from app.utils import DATETIME_FORMAT, hilite, scrub, utc_now
from app.errors import TotalRequestsError
from notifications_utils.recipients import RecipientCSV from notifications_utils.recipients import RecipientCSV
@@ -190,7 +189,11 @@ def save_sms(self, service_id, notification_id, encrypted_notification, sender_i
# Return False when trial mode services try sending notifications # Return False when trial mode services try sending notifications
# to non-team and non-simulated recipients. # to non-team and non-simulated recipients.
if not service_allowed_to_send_to(notification["to"], service, KeyType.NORMAL): if not service_allowed_to_send_to(notification["to"], service, KeyType.NORMAL):
current_app.logger.info(hilite(scrub(f"service not allowed to send to {notification['to']}, aborting"))) current_app.logger.info(
hilite(
scrub(f"service not allowed to send to {notification['to']}, aborting")
)
)
current_app.logger.debug( current_app.logger.debug(
"SMS {} failed as restricted service".format(notification_id) "SMS {} failed as restricted service".format(notification_id)
) )
@@ -221,7 +224,9 @@ def save_sms(self, service_id, notification_id, encrypted_notification, sender_i
) )
# Kick off sns process in provider_tasks.py # Kick off sns process in provider_tasks.py
current_app.logger.info(hilite(scrub(f"Going to deliver sms for recipient: {notification['to']}"))) current_app.logger.info(
hilite(scrub(f"Going to deliver sms for recipient: {notification['to']}"))
)
provider_tasks.deliver_sms.apply_async( provider_tasks.deliver_sms.apply_async(
[str(saved_notification.id)], queue=QueueNames.SEND_SMS [str(saved_notification.id)], queue=QueueNames.SEND_SMS
) )

View File

@@ -13,7 +13,6 @@ from app.enums import KeyType, NotificationStatus, NotificationType
from app.errors import BadRequestError from app.errors import BadRequestError
from app.models import Notification from app.models import Notification
from app.utils import hilite, scrub, utc_now from app.utils import hilite, scrub, utc_now
from app.errors import BadRequestError
from notifications_utils.recipients import ( from notifications_utils.recipients import (
format_email_address, format_email_address,
get_international_phone_info, get_international_phone_info,
@@ -111,7 +110,11 @@ def persist_notification(
formatted_recipient = validate_and_format_phone_number( formatted_recipient = validate_and_format_phone_number(
recipient, international=True recipient, international=True
) )
current_app.logger.info(hilite(scrub(f"Persisting notification with recipient {formatted_recipient}"))) current_app.logger.info(
hilite(
scrub(f"Persisting notification with recipient {formatted_recipient}")
)
)
recipient_info = get_international_phone_info(formatted_recipient) recipient_info = get_international_phone_info(formatted_recipient)
notification.normalised_to = formatted_recipient notification.normalised_to = formatted_recipient
notification.international = recipient_info.international notification.international = recipient_info.international

View File

@@ -99,7 +99,10 @@ def test_scrub():
result = scrub( result = scrub(
"This is a message with 17775554324, and also 18884449323 and also 17775554324" "This is a message with 17775554324, and also 18884449323 and also 17775554324"
) )
assert result == "This is a message with 1XXXXX54324, and also 1XXXXX49323 and also 1XXXXX54324" assert (
result
== "This is a message with 1XXXXX54324, and also 1XXXXX49323 and also 1XXXXX54324"
)
# This method is used for simulating bulk sends. We use localstack and run on a developer's machine to do the # This method is used for simulating bulk sends. We use localstack and run on a developer's machine to do the