diff --git a/app/delivery/send_to_providers.py b/app/delivery/send_to_providers.py index 54bb548958..50a5634048 100644 --- a/app/delivery/send_to_providers.py +++ b/app/delivery/send_to_providers.py @@ -356,7 +356,7 @@ def provider_to_use( notification_type (str): SMS or EMAIL. notification_id (UUID): id of notification. Just used for logging. to (str, optional): recipient. Defaults to None. - international (bool, optional): Flags whether or not the message is outside of Canada and the US. Defaults to False. + international (bool, optional): Flags whether or not the message recipient is outside of Canada and the US. Defaults to False. sender (str, optional): reply_to_text to use. Defaults to None. template_id (str, optional): template_id to use. Defaults to None. @@ -370,7 +370,6 @@ def provider_to_use( has_dedicated_number = sender is not None and sender.startswith("+1") cannot_determine_recipient_country = False sending_to_us_number = False - sending_internationally = False if to is not None: match = next(iter(phonenumbers.PhoneNumberMatcher(to, "US")), None) if match is None: @@ -379,19 +378,12 @@ def provider_to_use( phonenumbers.region_code_for_number(match.number) == "US" ): # The US is a special case that needs to send from a US toll free number sending_to_us_number = True - elif ( - phonenumbers.region_code_for_number(match.number) != "CA" - ): # Currently Pinpoint is having issues sending to non-Canadian numbers. - sending_internationally = True - using_sc_pool_template = template_id is not None and str(template_id) in current_app.config["AWS_PINPOINT_SC_TEMPLATE_IDS"] do_not_use_pinpoint = ( has_dedicated_number - or cannot_determine_recipient_country - or international # Defaulting back to SNS: it's not entirely clear what this flag is for. Not always set for international recipients. or sending_to_us_number - or sending_internationally + or cannot_determine_recipient_country or not current_app.config["AWS_PINPOINT_SC_POOL_ID"] or ((not current_app.config["AWS_PINPOINT_DEFAULT_POOL_ID"]) and not using_sc_pool_template) ) diff --git a/tests/app/delivery/test_send_to_providers.py b/tests/app/delivery/test_send_to_providers.py index 2134a40029..a45e295237 100644 --- a/tests/app/delivery/test_send_to_providers.py +++ b/tests/app/delivery/test_send_to_providers.py @@ -110,17 +110,6 @@ def test_should_use_sns_for_sms_if_sending_to_the_US(self, restore_provider_deta provider = send_to_providers.provider_to_use("sms", "1234", "+17065551234") assert provider.name == "sns" - def test_should_use_sns_for_sms_if_sending_internationally(self, restore_provider_details, notify_api): - with set_config_values( - notify_api, - { - "AWS_PINPOINT_SC_POOL_ID": "sc_pool_id", - "AWS_PINPOINT_DEFAULT_POOL_ID": "default_pool_id", - }, - ): - provider = send_to_providers.provider_to_use("sms", "1234", "+4408456021111") # British Telecom test line - assert provider.name == "sns" - def test_should_use_sns_for_sms_if_match_fails(self, restore_provider_details, notify_api): with set_config_values( notify_api,