make sure BOUNCE_PREFIX_FOR_REPLY_PHASE can't be used as directory name or for creating aliases on-the-fly
This commit is contained in:
parent
a918cc3670
commit
2f96322977
|
@ -3,6 +3,7 @@ from typing import Optional
|
|||
|
||||
from sqlalchemy.exc import IntegrityError, DataError
|
||||
|
||||
from app.config import BOUNCE_PREFIX_FOR_REPLY_PHASE
|
||||
from app.email_utils import (
|
||||
get_email_domain_part,
|
||||
send_cannot_create_directory_alias,
|
||||
|
@ -29,6 +30,12 @@ from app.models import (
|
|||
|
||||
def try_auto_create(address: str) -> Optional[Alias]:
|
||||
"""Try to auto-create the alias using directory or catch-all domain"""
|
||||
if address.startswith(f"{BOUNCE_PREFIX_FOR_REPLY_PHASE}+"):
|
||||
LOG.exception(
|
||||
"alias %s can't start with %s", address, BOUNCE_PREFIX_FOR_REPLY_PHASE
|
||||
)
|
||||
return None
|
||||
|
||||
alias = try_auto_create_catch_all_domain(address)
|
||||
if not alias:
|
||||
alias = try_auto_create_directory(address)
|
||||
|
|
|
@ -3,7 +3,12 @@ from flask_login import login_required, current_user
|
|||
from flask_wtf import FlaskForm
|
||||
from wtforms import StringField, validators
|
||||
|
||||
from app.config import EMAIL_DOMAIN, ALIAS_DOMAINS, MAX_NB_DIRECTORY
|
||||
from app.config import (
|
||||
EMAIL_DOMAIN,
|
||||
ALIAS_DOMAINS,
|
||||
MAX_NB_DIRECTORY,
|
||||
BOUNCE_PREFIX_FOR_REPLY_PHASE,
|
||||
)
|
||||
from app.dashboard.base import dashboard_bp
|
||||
from app.extensions import db
|
||||
from app.models import Directory, Mailbox, DirectoryMailbox
|
||||
|
@ -126,6 +131,7 @@ def directory():
|
|||
"bounces",
|
||||
"bounce",
|
||||
"transactional",
|
||||
BOUNCE_PREFIX_FOR_REPLY_PHASE,
|
||||
):
|
||||
flash(
|
||||
"this directory name is reserved, please choose another name",
|
||||
|
|
|
@ -370,7 +370,7 @@ def send_email_at_most_times(
|
|||
return True
|
||||
|
||||
|
||||
def get_email_local_part(address):
|
||||
def get_email_local_part(address) -> str:
|
||||
"""
|
||||
Get the local part from email
|
||||
ab@cd.com -> ab
|
||||
|
|
Loading…
Reference in a new issue