fix domain can be null in self-hosting

# Conflicts:
#	app/api/views/new_custom_alias.py
#	app/dashboard/views/custom_alias.py
This commit is contained in:
Son NK 2020-05-27 22:13:43 +02:00 committed by Son NK
parent 4906d3a4a8
commit 1a22d0cf9b
3 changed files with 7 additions and 4 deletions

View File

@ -85,8 +85,9 @@ def new_custom_alias():
if alias_suffix.startswith("@"):
alias_domain = alias_suffix[1:]
domain = CustomDomain.get_by(domain=alias_domain)
LOG.d("set alias %s to domain %s", full_alias, domain)
alias.custom_domain_id = domain.id
if domain:
LOG.d("set alias %s to domain %s", full_alias, domain)
alias.custom_domain_id = domain.id
db.session.commit()

View File

@ -130,7 +130,8 @@ def custom_alias():
)
return redirect(url_for("dashboard.custom_alias"))
custom_domain_id = domain.id
if domain:
custom_domain_id = domain.id
alias = Alias.create(
user_id=current_user.id,

View File

@ -192,7 +192,8 @@ def authorize():
if alias_suffix.startswith("@"):
alias_domain = alias_suffix[1:]
domain = CustomDomain.get_by(domain=alias_domain)
alias.custom_domain_id = domain.id
if domain:
alias.custom_domain_id = domain.id
db.session.flush()
flash(f"Alias {full_alias} has been created", "success")