Skip to content

Commit

Permalink
Merge branch 'main' into pinpoint-for-everyone
Browse files Browse the repository at this point in the history
  • Loading branch information
sastels authored May 9, 2024
2 parents ea7f071 + 6770073 commit 70e540c
Show file tree
Hide file tree
Showing 12 changed files with 124 additions and 8 deletions.
4 changes: 2 additions & 2 deletions .devcontainer/docker-compose.yml
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand All @@ -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:
Expand Down
2 changes: 1 addition & 1 deletion .env.example
Original file line number Diff line number Diff line change
Expand Up @@ -22,4 +22,4 @@ CONTACT_FORM_EMAIL_ADDRESS = ""

AWS_PINPOINT_SC_POOL_ID=
AWS_PINPOINT_SC_TEMPLATE_IDS=
AWS_PINPOINT_LC_POOL_ID=
AWS_PINPOINT_DEFAULT_POOL_ID=
2 changes: 1 addition & 1 deletion .github/workflows/test.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
6 changes: 6 additions & 0 deletions app/clients/freshdesk.py
Original file line number Diff line number Diff line change
Expand Up @@ -62,13 +62,19 @@ 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}",
"<hr>",
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}",
f"- Nom du service : {self.contact.service_name}",
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}",
]
)

Expand Down
2 changes: 2 additions & 0 deletions app/config.py
Original file line number Diff line number Diff line change
Expand Up @@ -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"
Expand Down Expand Up @@ -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
Expand Down
1 change: 1 addition & 0 deletions app/user/contact_request.py
Original file line number Diff line number Diff line change
Expand Up @@ -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="")

Expand Down
1 change: 1 addition & 0 deletions app/user/rest.py
Original file line number Diff line number Diff line change
Expand Up @@ -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"],
)
Expand Down
2 changes: 1 addition & 1 deletion ci/Dockerfile.test
Original file line number Diff line number Diff line change
@@ -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"
Expand Down
2 changes: 1 addition & 1 deletion docker-compose.yml
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
2 changes: 1 addition & 1 deletion local/Dockerfile
Original file line number Diff line number Diff line change
@@ -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"
Expand Down
97 changes: 97 additions & 0 deletions migrations/versions/0449_update_magic_link_auth.py
Original file line number Diff line number Diff line change
@@ -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'")
11 changes: 10 additions & 1 deletion tests/app/clients/test_freshdesk.py
Original file line number Diff line number Diff line change
Expand Up @@ -130,13 +130,19 @@ def match_json(request):
"- Organisation id: 6b72e84f-8591-42e1-93b8-7d24a45e1d79<br>"
"- Organisation name: best org name ever<br>"
"- Logo filename: branding_url<br>"
"- Logo name: branding_logo_name<br>"
"- Alt text english: en alt text<br>"
"- Alt text french: fr alt text<br>"
"<hr><br>"
"Un nouveau logo a été téléchargé par name ([email protected]) pour le service suivant :<br>"
"- Identifiant du service : 8624bd36-b70b-4d4b-a459-13e1f4770b92<br>"
"- Nom du service : t6<br>"
"- Identifiant de l'organisation: 6b72e84f-8591-42e1-93b8-7d24a45e1d79<br>"
"- Nom de l'organisation: best org name ever<br>"
"- Nom du fichier du logo : branding_url",
"- Nom du fichier du logo : branding_url<br>"
"- Nom du logo : branding_logo_name<br>"
"- Texte alternatif anglais : en alt text<br>"
"- Texte alternatif français : fr alt text",
"email": "[email protected]",
"priority": 1,
"status": 2,
Expand Down Expand Up @@ -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()
Expand Down

0 comments on commit 70e540c

Please sign in to comment.