PR comments

This commit is contained in:
Adrià Casajús 2022-05-12 18:42:16 +02:00
parent 39b035a123
commit bfb1ae6371
No known key found for this signature in database
GPG Key ID: F0033226A5AFC9B9
3 changed files with 4 additions and 8 deletions

View File

@ -25,6 +25,7 @@ from app.errors import (
) )
from app.log import LOG from app.log import LOG
from app.models import Alias, Contact, EmailLog, User from app.models import Alias, Contact, EmailLog, User
from app.utils import sanitize_email
def email_validator(): def email_validator():
@ -65,6 +66,7 @@ def create_contact(user: User, alias: Alias, contact_address: str) -> Contact:
except ValueError: except ValueError:
raise ErrAddressInvalid(contact_address) raise ErrAddressInvalid(contact_address)
contact_email = sanitize_email(contact_email)
if not is_valid_email(contact_email): if not is_valid_email(contact_email):
raise ErrAddressInvalid(contact_email) raise ErrAddressInvalid(contact_email)

View File

@ -88,7 +88,7 @@ class ErrContactAlreadyExists(SLException):
"""raised when a contact already exists""" """raised when a contact already exists"""
# TODO: type-hint this as a contact when models are almost dataclasses and don't import errors # 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 self.contact = contact
def error_for_user(self) -> str: def error_for_user(self) -> str:

View File

@ -4,12 +4,6 @@
container_name=sl-db-new-migration 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 # create a postgres database for SimpleLogin
docker rm -f ${container_name} docker rm -f ${container_name}
docker run -p 25432:5432 --name ${container_name} -e POSTGRES_PASSWORD=postgres -e POSTGRES_DB=sl -d postgres:13 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 env DB_URI=postgresql://postgres:postgres@127.0.0.1:25432/sl poetry run alembic upgrade head
# generate the migration script. # 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 # remove the db
docker rm -f ${container_name} docker rm -f ${container_name}