diff --git a/.devcontainer/docker-compose.yml b/.devcontainer/docker-compose.yml index 328816279b..19b03edfa9 100644 --- a/.devcontainer/docker-compose.yml +++ b/.devcontainer/docker-compose.yml @@ -20,7 +20,7 @@ services: - db db: - image: postgres:11.20-bullseye@sha256:98fac4e8dc6fb58a75f2be563e876842f53db5baadb0d98abdd3205a20f6e6eb + image: postgres:11.22-bullseye@sha256:c886a3236b3d11abc302e64309186c90a69b49e53ccff23fd8c8b057b5b4bce9 volumes: - ./initdb:/docker-entrypoint-initdb.d restart: always @@ -38,7 +38,7 @@ services: - "5432:5432" redis: - image: redis:6.2@sha256:9e75c88539241ad7f61bc9c39ea4913b354064b8a75ca5fc40e1cef41b645bc0 + image: redis:6.2@sha256:d4948d011cc38e94f0aafb8f9a60309bd93034e07d10e0767af534512cf012a9 restart: always command: redis-server --port 6380 ports: diff --git a/.env.example b/.env.example index 8e7042fbda..6557dd4a88 100644 --- a/.env.example +++ b/.env.example @@ -22,4 +22,4 @@ CONTACT_FORM_EMAIL_ADDRESS = "" AWS_PINPOINT_SC_POOL_ID= AWS_PINPOINT_SC_TEMPLATE_IDS= -AWS_PINPOINT_LC_POOL_ID= \ No newline at end of file +AWS_PINPOINT_DEFAULT_POOL_ID= diff --git a/.github/workflows/test.yaml b/.github/workflows/test.yaml index fb65539f1f..4f9a621187 100644 --- a/.github/workflows/test.yaml +++ b/.github/workflows/test.yaml @@ -6,7 +6,7 @@ jobs: runs-on: ubuntu-latest services: postgres: - image: postgres:11.20-bullseye@sha256:4e4b23580ada59c9ec5a712bdff9f91b0e6a7898d9ea954306b953c426727cef + image: postgres:11.22-bullseye@sha256:c886a3236b3d11abc302e64309186c90a69b49e53ccff23fd8c8b057b5b4bce9 env: POSTGRES_USER: postgres POSTGRES_PASSWORD: postgres diff --git a/app/clients/freshdesk.py b/app/clients/freshdesk.py index 66c97546fa..fd0ecc978b 100644 --- a/app/clients/freshdesk.py +++ b/app/clients/freshdesk.py @@ -62,6 +62,9 @@ def _generate_description(self): f"- Organisation id: {self.contact.organisation_id}", f"- Organisation name: {self.contact.department_org_name}", f"- Logo filename: {self.contact.branding_url}", + f"- Logo name: {self.contact.branding_logo_name}", + f"- Alt text english: {self.contact.alt_text_en}", + f"- Alt text french: {self.contact.alt_text_fr}", "
", f"Un nouveau logo a été téléchargé par {self.contact.name} ({self.contact.email_address}) pour le service suivant :", f"- Identifiant du service : {self.contact.service_id}", @@ -69,6 +72,9 @@ def _generate_description(self): f"- Identifiant de l'organisation: {self.contact.organisation_id}", f"- Nom de l'organisation: {self.contact.department_org_name}", f"- Nom du fichier du logo : {self.contact.branding_url}", + f"- Nom du logo : {self.contact.branding_logo_name}", + f"- Texte alternatif anglais : {self.contact.alt_text_en}", + f"- Texte alternatif français : {self.contact.alt_text_fr}", ] ) diff --git a/app/config.py b/app/config.py index 2113a9c733..aab8422f27 100644 --- a/app/config.py +++ b/app/config.py @@ -304,6 +304,7 @@ class Config(object): INVITATION_EMAIL_TEMPLATE_ID = "4f46df42-f795-4cc4-83bb-65ca312f49cc" SMS_CODE_TEMPLATE_ID = "36fb0730-6259-4da1-8a80-c8de22ad4246" EMAIL_2FA_TEMPLATE_ID = "299726d2-dba6-42b8-8209-30e1d66ea164" + EMAIL_MAGIC_LINK_TEMPLATE_ID = "6e97fd09-6da0-4cc8-829d-33cf5b818103" NEW_USER_EMAIL_VERIFICATION_TEMPLATE_ID = "ece42649-22a8-4d06-b87f-d52d5d3f0a27" PASSWORD_RESET_TEMPLATE_ID = "474e9242-823b-4f99-813d-ed392e7f1201" FORCED_PASSWORD_RESET_TEMPLATE_ID = "e9a65a6b-497b-42f2-8f43-1736e43e13b3" @@ -361,6 +362,7 @@ class Config(object): "app.celery.scheduled_tasks", "app.celery.reporting_tasks", "app.celery.nightly_tasks", + "app.celery.process_pinpoint_receipts_tasks", ) CELERYBEAT_SCHEDULE = { # app/celery/scheduled_tasks.py diff --git a/app/user/contact_request.py b/app/user/contact_request.py index 74c5a96a35..cfca30cafb 100644 --- a/app/user/contact_request.py +++ b/app/user/contact_request.py @@ -31,6 +31,7 @@ class ContactRequest: notification_types: str = field(default="") expected_volume: str = field(default="") branding_url: str = field(default="") + branding_logo_name: str = field(default="") alt_text_en: str = field(default="") alt_text_fr: str = field(default="") diff --git a/app/user/rest.py b/app/user/rest.py index a80e280548..ea28646d41 100644 --- a/app/user/rest.py +++ b/app/user/rest.py @@ -500,6 +500,7 @@ def send_branding_request(user_id): organisation_id=data["organisation_id"], department_org_name=data["organisation_name"], branding_url=get_logo_url(data["filename"]), + branding_logo_name=data["branding_logo_name"] if "branding_logo_name" in data else "", alt_text_en=data["alt_text_en"], alt_text_fr=data["alt_text_fr"], ) diff --git a/ci/Dockerfile.test b/ci/Dockerfile.test index e068dfbfd5..3a5874db57 100644 --- a/ci/Dockerfile.test +++ b/ci/Dockerfile.test @@ -1,6 +1,6 @@ # Heavily inspired from Dockerfile, this one also install requirements_for_test.txt -FROM python:3.10-alpine@sha256:860f632e67178d9e90c7dfa9844a5e02098220bff5716d3c2fe1870325f00853 +FROM python:3.10-alpine@sha256:7edffe5acc6a2c4c009fece2fbdc85f04fde4c8481202473b880ef3f8fbb2939 ENV PYTHONDONTWRITEBYTECODE 1 ENV POETRY_VERSION "1.7.1" diff --git a/docker-compose.yml b/docker-compose.yml index 610d8dc306..443727d0c6 100644 --- a/docker-compose.yml +++ b/docker-compose.yml @@ -18,7 +18,7 @@ services: - "listen_addresses=*" restart: always redis: - image: redis:6.2@sha256:9e75c88539241ad7f61bc9c39ea4913b354064b8a75ca5fc40e1cef41b645bc0 + image: redis:6.2@sha256:d4948d011cc38e94f0aafb8f9a60309bd93034e07d10e0767af534512cf012a9 web: image: notification-api restart: always diff --git a/local/Dockerfile b/local/Dockerfile index f4ea41376c..8c0e128f7a 100644 --- a/local/Dockerfile +++ b/local/Dockerfile @@ -1,4 +1,4 @@ -FROM python:3.10-alpine@sha256:860f632e67178d9e90c7dfa9844a5e02098220bff5716d3c2fe1870325f00853 +FROM python:3.10-alpine@sha256:7edffe5acc6a2c4c009fece2fbdc85f04fde4c8481202473b880ef3f8fbb2939 ENV PYTHONDONTWRITEBYTECODE 1 ENV POETRY_VERSION "1.7.1" diff --git a/migrations/versions/0449_update_magic_link_auth.py b/migrations/versions/0449_update_magic_link_auth.py new file mode 100644 index 0000000000..6e29d5501c --- /dev/null +++ b/migrations/versions/0449_update_magic_link_auth.py @@ -0,0 +1,97 @@ +""" + +Revision ID: 0448_update_verify_code2 +Revises: 0449_update_magic_link_auth +Create Date: 2023-10-05 00:00:00 + +""" +from datetime import datetime + +from alembic import op +from flask import current_app + +revision = "0449_update_magic_link_auth" +down_revision = "0448_update_verify_code2" + +near_content = "\n".join( + [ + "[[en]]" + "Hi ((name))," + "" + "Here is your magic link to log in to GC Notify:" + "" + "^ **[Sign-in](((link_url_en)))**" + "[[/en]]" + "" + "---" + "" + "[[fr]]" + "Bonjour ((name))," + "" + "Voici votre lien magique pour vous connecter à Notification GC:" + "" + "^ **[Connectez-vous](((link_url_fr)))**" + "[[/fr]]" + ] +) + + +template = { + "id": current_app.config["EMAIL_MAGIC_LINK_TEMPLATE_ID"], + "template_type": "email", + "subject": "Sign in | Connectez-vous", + "content": near_content, + "process_type": "priority", + "name": "Sign in - Magic Link | Se connecter - Lien magique", +} + + +def upgrade(): + conn = op.get_bind() + + template_insert = """ + INSERT INTO templates (id, name, template_type, created_at, updated_at, content, service_id, subject, created_by_id, version, archived, process_type, hidden) + VALUES ('{}', '{}', '{}', '{}', '{}', '{}', '{}', '{}', '{}', '{}', false, '{}', false) + """ + + template_history_insert = """ + INSERT INTO templates_history (id, name, template_type, created_at, content, archived, service_id, subject, + created_by_id, version, process_type, hidden) + VALUES ('{}', '{}', '{}', '{}', '{}', False, '{}', '{}', '{}', {}, '{}', false) + """ + op.execute( + template_insert.format( + template["id"], + template["name"], + template["template_type"], + datetime.utcnow(), + datetime.utcnow(), + template["content"], + current_app.config["NOTIFY_SERVICE_ID"], + template["subject"], + current_app.config["NOTIFY_USER_ID"], + 1, + template["process_type"], + ) + ) + + op.execute( + template_history_insert.format( + template["id"], + template["name"], + template["template_type"], + datetime.utcnow(), + template["content"], + current_app.config["NOTIFY_SERVICE_ID"], + template["subject"], + current_app.config["NOTIFY_USER_ID"], + 1, + template["process_type"], + ) + ) + + op.execute("INSERT INTO auth_type (name) VALUES ('magic_link')") + + +def downgrade(): + op.execute("DELETE FROM auth_type WHERE name = 'magic_link'") diff --git a/tests/app/clients/test_freshdesk.py b/tests/app/clients/test_freshdesk.py index a3e0713d5f..3e8b56227d 100644 --- a/tests/app/clients/test_freshdesk.py +++ b/tests/app/clients/test_freshdesk.py @@ -130,13 +130,19 @@ def match_json(request): "- Organisation id: 6b72e84f-8591-42e1-93b8-7d24a45e1d79
" "- Organisation name: best org name ever
" "- Logo filename: branding_url
" + "- Logo name: branding_logo_name
" + "- Alt text english: en alt text
" + "- Alt text french: fr alt text
" "

" "Un nouveau logo a été téléchargé par name (test@email.com) pour le service suivant :
" "- Identifiant du service : 8624bd36-b70b-4d4b-a459-13e1f4770b92
" "- Nom du service : t6
" "- Identifiant de l'organisation: 6b72e84f-8591-42e1-93b8-7d24a45e1d79
" "- Nom de l'organisation: best org name ever
" - "- Nom du fichier du logo : branding_url", + "- Nom du fichier du logo : branding_url
" + "- Nom du logo : branding_logo_name
" + "- Texte alternatif anglais : en alt text
" + "- Texte alternatif français : fr alt text", "email": "test@email.com", "priority": 1, "status": 2, @@ -166,6 +172,9 @@ def match_json(request): "department_org_name": "best org name ever", "service_id": "8624bd36-b70b-4d4b-a459-13e1f4770b92", "branding_url": "branding_url", + "branding_logo_name": "branding_logo_name", + "alt_text_en": "en alt text", + "alt_text_fr": "fr alt text", } with notify_api.app_context(): response = freshdesk.Freshdesk(ContactRequest(**data)).send_ticket()