Skip to content

Commit c497c28

Browse files
authored
Merge pull request #1654 from GSA/main
04/15/2025 Production Deploy
2 parents b34ea8a + db90cec commit c497c28

27 files changed

+489
-685
lines changed

Makefile

+15-1
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,8 @@ DATE = $(shell date +%Y-%m-%d:%H:%M:%S)
55
APP_VERSION_FILE = app/version.py
66

77
GIT_BRANCH ?= $(shell git symbolic-ref --short HEAD 2> /dev/null || echo "detached")
8-
GIT_COMMIT ?= $(shell git rev-parse HEAD)
8+
GIT_COMMIT ?= $(shell git rev-parse HEAD 2> /dev/null || echo "")
9+
GIT_HOOKS_PATH ?= $(shell git config --global core.hooksPath || echo "")
910

1011
## DEVELOPMENT
1112

@@ -23,6 +24,19 @@ bootstrap: ## Set up everything to run the app
2324
createdb test_notification_api || true
2425
(poetry run flask db upgrade) || true
2526

27+
.PHONY: bootstrap-with-git-hooks
28+
bootstrap-with-git-hooks: ## Sets everything up and accounts for pre-existing git hooks
29+
make generate-version-file
30+
poetry self add poetry-dotenv-plugin
31+
poetry lock --no-update
32+
poetry install --sync --no-root
33+
git config --global --unset-all core.hooksPath
34+
poetry run pre-commit install
35+
git config --global core.hookspath "${GIT_HOOKS_PATH}"
36+
createdb notification_api || true
37+
createdb test_notification_api || true
38+
(poetry run flask db upgrade) || true
39+
2640
.PHONY: bootstrap-with-docker
2741
bootstrap-with-docker: ## Build the image to run the app in Docker
2842
docker build -f docker/Dockerfile -t notifications-api .

app/clients/document_download.py

+1-1
Original file line numberDiff line numberDiff line change
@@ -33,7 +33,7 @@ def upload_document(self, service_id, file_contents, is_csv=None):
3333
"document": file_contents,
3434
"is_csv": is_csv or False,
3535
},
36-
timeout=30
36+
timeout=30,
3737
)
3838

3939
response.raise_for_status()

app/clients/performance_platform/performance_platform_client.py

+1-1
Original file line numberDiff line numberDiff line change
@@ -29,7 +29,7 @@ def send_stats_to_performance_platform(self, payload):
2929
self.performance_platform_url + payload["dataType"],
3030
json=payload,
3131
headers=headers,
32-
timeout=30
32+
timeout=30,
3333
)
3434

3535
if resp.status_code == 200:

app/clients/sms/aws_sns.py

+4-1
Original file line numberDiff line numberDiff line change
@@ -48,7 +48,10 @@ def _valid_sender_number(self, sender):
4848

4949
def send_sms(self, to, content, reference, sender=None, international=False):
5050
matched = False
51-
for match in phonenumbers.PhoneNumberMatcher(to, "US"):
51+
if "+" not in to:
52+
to = f"+{to}"
53+
54+
for match in phonenumbers.PhoneNumberMatcher(to, None):
5255
matched = True
5356
to = phonenumbers.format_number(
5457
match.number, phonenumbers.PhoneNumberFormat.E164

app/cronitor.py

+1-1
Original file line numberDiff line numberDiff line change
@@ -35,7 +35,7 @@ def ping_cronitor(command):
3535
params={
3636
"host": current_app.config["API_HOST_NAME"],
3737
},
38-
timeout=30
38+
timeout=30,
3939
)
4040
resp.raise_for_status()
4141
except requests.RequestException as e:

app/delivery/send_to_providers.py

+11
Original file line numberDiff line numberDiff line change
@@ -105,6 +105,17 @@ def send_sms_to_provider(notification):
105105
# The future home of the validation is TBD
106106
_experimentally_validate_phone_numbers(recipient)
107107

108+
# TODO current we allow US phone numbers to be uploaded without the country code (1)
109+
# This will break certain international phone numbers (Norway, Denmark, East Timor)
110+
# When we officially announce support for international numbers, US numbers must contain
111+
# their country code.
112+
recipient = str(recipient)
113+
if len(recipient) == 10:
114+
if os.getenv("NOTIFY_ENVIRONMENT") not in [
115+
"test"
116+
]: # we want to test intl support
117+
recipient = f"1{recipient}"
118+
108119
sender_numbers = get_sender_numbers(notification)
109120
if notification.reply_to_text not in sender_numbers:
110121
raise ValueError(

migrations/versions/0216_remove_colours.py

+1-1
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@
22
Revision ID: 0216_remove_colours
33
Revises: 0215_email_brand_type
44
Create Date: 2018-08-24 13:36:49.346156
5-
"""
5+
"""
66

77
import sqlalchemy as sa
88
from alembic import op

migrations/versions/0219_default_email_branding.py

+1-1
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@
22
Revision ID: 0219_default_email_branding
33
Revises: 0216_remove_colours
44
Create Date: 2018-08-24 13:36:49.346156
5-
"""
5+
"""
66

77
from alembic import op
88
from sqlalchemy import text

migrations/versions/0220_email_brand_type_non_null.py

+1-1
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@
22
Revision ID: 0220_email_brand_type_non_null
33
Revises: 0219_default_email_branding
44
Create Date: 2018-08-24 13:36:49.346156
5-
"""
5+
"""
66

77
from alembic import op
88

migrations/versions/0221_nullable_service_branding.py

+1-1
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@
22
Revision ID: 0221_nullable_service_branding
33
Revises: 0220_email_brand_type_non_null
44
Create Date: 2018-08-24 13:36:49.346156
5-
"""
5+
"""
66

77
from alembic import op
88

migrations/versions/0222_drop_service_branding.py

+1-1
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@
22
Revision ID: 0222_drop_service_branding
33
Revises: 0221_nullable_service_branding
44
Create Date: 2018-08-24 13:36:49.346156
5-
"""
5+
"""
66

77
import sqlalchemy as sa
88
from alembic import op

migrations/versions/0223_add_domain_constraint.py

+1-1
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@
22
Revision ID: 0223_add_domain_constraint
33
Revises: 0222_drop_service_branding
44
Create Date: 2018-08-24 13:36:49.346156
5-
"""
5+
"""
66

77
from alembic import op
88

notifications_utils/formatters.py

+7-7
Original file line numberDiff line numberDiff line change
@@ -12,15 +12,15 @@
1212
from . import email_with_smart_quotes_regex
1313

1414
OBSCURE_ZERO_WIDTH_WHITESPACE = (
15-
"\u180E" # Mongolian vowel separator
16-
"\u200B" # zero width space
17-
"\u200C" # zero width non-joiner
18-
"\u200D" # zero width joiner
15+
"\u180e" # Mongolian vowel separator
16+
"\u200b" # zero width space
17+
"\u200c" # zero width non-joiner
18+
"\u200d" # zero width joiner
1919
"\u2060" # word joiner
20-
"\uFEFF" # zero width non-breaking space
20+
"\ufeff" # zero width non-breaking space
2121
)
2222

23-
OBSCURE_FULL_WIDTH_WHITESPACE = "\u00A0" # non breaking space
23+
OBSCURE_FULL_WIDTH_WHITESPACE = "\u00a0" # non breaking space
2424

2525
ALL_WHITESPACE = (
2626
string.whitespace + OBSCURE_ZERO_WIDTH_WHITESPACE + OBSCURE_FULL_WIDTH_WHITESPACE
@@ -61,7 +61,7 @@
6161
def unlink_govuk_escaped(message):
6262
return re.sub(
6363
govuk_not_a_link,
64-
r"\1\2\3" + ".\u200B" + r"\4", # Unicode zero-width space
64+
r"\1\2\3" + ".\u200b" + r"\4", # Unicode zero-width space
6565
message,
6666
)
6767

notifications_utils/recipients.py

-2
Original file line numberDiff line numberDiff line change
@@ -628,8 +628,6 @@ def validate_phone_number(number, international=False):
628628

629629
try:
630630
parsed = phonenumbers.parse(number, None)
631-
if parsed.country_code != 1:
632-
raise InvalidPhoneError("Invalid country code")
633631
number = f"{parsed.country_code}{parsed.national_number}"
634632
if len(number) < 8:
635633
raise InvalidPhoneError("Not enough digits")

notifications_utils/sanitise_text.py

+6-6
Original file line numberDiff line numberDiff line change
@@ -15,13 +15,13 @@ class SanitiseText:
1515
"’": "'", # RIGHT SINGLE QUOTATION MARK (U+2019)
1616
"“": '"', # LEFT DOUBLE QUOTATION MARK (U+201C)
1717
"”": '"', # RIGHT DOUBLE QUOTATION MARK (U+201D)
18-
"\u180E": "", # Mongolian vowel separator
19-
"\u200B": "", # zero width space
20-
"\u200C": "", # zero width non-joiner
21-
"\u200D": "", # zero width joiner
18+
"\u180e": "", # Mongolian vowel separator
19+
"\u200b": "", # zero width space
20+
"\u200c": "", # zero width non-joiner
21+
"\u200d": "", # zero width joiner
2222
"\u2060": "", # word joiner
23-
"\uFEFF": "", # zero width non-breaking space
24-
"\u00A0": " ", # NON BREAKING WHITE SPACE (U+200B)
23+
"\ufeff": "", # zero width non-breaking space
24+
"\u00a0": " ", # NON BREAKING WHITE SPACE (U+200B)
2525
"\t": " ", # TAB
2626
}
2727

0 commit comments

Comments
 (0)