From bfb1ae637173c131d21b3840576e0e1a7b89d69e Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Adri=C3=A0=20Casaj=C3=BAs?= Date: Thu, 12 May 2022 18:42:16 +0200 Subject: [PATCH] PR comments --- app/dashboard/views/alias_contact_manager.py | 2 ++ app/errors.py | 2 +- scripts/new-migration.sh | 8 +------- 3 files changed, 4 insertions(+), 8 deletions(-) diff --git a/app/dashboard/views/alias_contact_manager.py b/app/dashboard/views/alias_contact_manager.py index 8f755292..9df31ca8 100644 --- a/app/dashboard/views/alias_contact_manager.py +++ b/app/dashboard/views/alias_contact_manager.py @@ -25,6 +25,7 @@ from app.errors import ( ) from app.log import LOG from app.models import Alias, Contact, EmailLog, User +from app.utils import sanitize_email def email_validator(): @@ -65,6 +66,7 @@ def create_contact(user: User, alias: Alias, contact_address: str) -> Contact: except ValueError: raise ErrAddressInvalid(contact_address) + contact_email = sanitize_email(contact_email) if not is_valid_email(contact_email): raise ErrAddressInvalid(contact_email) diff --git a/app/errors.py b/app/errors.py index 9d14d272..ede8ac2d 100644 --- a/app/errors.py +++ b/app/errors.py @@ -88,7 +88,7 @@ class ErrContactAlreadyExists(SLException): """raised when a contact already exists""" # TODO: type-hint this as a contact when models are almost dataclasses and don't import errors - def __init__(self, contact): + def __init__(self, contact: "Contact"): # noqa: F821 self.contact = contact def error_for_user(self) -> str: diff --git a/scripts/new-migration.sh b/scripts/new-migration.sh index c0f0023d..da11a756 100755 --- a/scripts/new-migration.sh +++ b/scripts/new-migration.sh @@ -4,12 +4,6 @@ container_name=sl-db-new-migration -if [ "$#" -lt "1" ]; then - echo "What is this migration for?" - exit 1 -fi -reason="$@" - # create a postgres database for SimpleLogin docker rm -f ${container_name} docker run -p 25432:5432 --name ${container_name} -e POSTGRES_PASSWORD=postgres -e POSTGRES_DB=sl -d postgres:13 @@ -21,7 +15,7 @@ sleep 3 env DB_URI=postgresql://postgres:postgres@127.0.0.1:25432/sl poetry run alembic upgrade head # generate the migration script. -env DB_URI=postgresql://postgres:postgres@127.0.0.1:25432/sl poetry run alembic revision --autogenerate -m "$reason" +env DB_URI=postgresql://postgres:postgres@127.0.0.1:25432/sl poetry run alembic revision --autogenerate $@ # remove the db docker rm -f ${container_name}