Skip to content

Commit

Permalink
Merge branch 'main' into rough-in-pinpoint
Browse files Browse the repository at this point in the history
  • Loading branch information
sastels authored May 8, 2024
2 parents 7fb51e1 + 5206d78 commit 7723702
Show file tree
Hide file tree
Showing 7 changed files with 104 additions and 6 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 .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
1 change: 1 addition & 0 deletions app/config.py
Original file line number Diff line number Diff line change
Expand Up @@ -303,6 +303,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
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'")

0 comments on commit 7723702

Please sign in to comment.