make sure alias that starts with bounce prefix can't be automatically created

This commit is contained in:
Son 2022-01-05 15:16:04 +01:00
parent de23828df1
commit 6cb55e27f3
1 changed files with 5 additions and 1 deletions

View File

@ -4,7 +4,7 @@ from typing import Optional
from email_validator import validate_email, EmailNotValidError
from sqlalchemy.exc import IntegrityError, DataError
from app.config import BOUNCE_PREFIX_FOR_REPLY_PHASE
from app.config import BOUNCE_PREFIX_FOR_REPLY_PHASE, BOUNCE_PREFIX
from app.db import Session
from app.email_utils import (
get_email_domain_part,
@ -37,6 +37,10 @@ def try_auto_create(address: str) -> Optional[Alias]:
LOG.e("alias %s can't start with %s", address, BOUNCE_PREFIX_FOR_REPLY_PHASE)
return None
if address.startswith(BOUNCE_PREFIX):
LOG.e("alias %s can't start with %s", address, BOUNCE_PREFIX)
return None
try:
# NOT allow unicode for now
validate_email(address, check_deliverability=False, allow_smtputf8=False)