This commit is contained in:
Son NK 2020-04-05 12:19:17 +02:00
parent fa8e0aee45
commit 9c22bf479a

View file

@ -68,7 +68,7 @@ def alias_contact_manager(alias_id):
if request.method == "POST": if request.method == "POST":
if request.form.get("form-name") == "create": if request.form.get("form-name") == "create":
if new_contact_form.validate(): if new_contact_form.validate():
contact_email = new_contact_form.email.data.strip() contact_addr = new_contact_form.email.data.strip()
# generate a reply_email, make sure it is unique # generate a reply_email, make sure it is unique
# not use while to avoid infinite loop # not use while to avoid infinite loop
@ -78,13 +78,13 @@ def alias_contact_manager(alias_id):
if not Contact.get_by(reply_email=reply_email): if not Contact.get_by(reply_email=reply_email):
break break
_, website_email = parseaddr(contact_email) _, contact_email = parseaddr(contact_addr)
website_email = website_email.lower() contact_email = contact_email.lower()
contact = Contact.get_by(alias_id=alias.id, website_email=website_email) contact = Contact.get_by(alias_id=alias.id, website_email=contact_email)
# already been added # already been added
if contact: if contact:
flash(f"{website_email} is already added", "error") flash(f"{contact_email} is already added", "error")
return redirect( return redirect(
url_for( url_for(
"dashboard.alias_contact_manager", "dashboard.alias_contact_manager",
@ -96,14 +96,14 @@ def alias_contact_manager(alias_id):
contact = Contact.create( contact = Contact.create(
user_id=alias.user_id, user_id=alias.user_id,
alias_id=alias.id, alias_id=alias.id,
website_email=website_email, website_email=contact_email,
website_from=contact_email, website_from=contact_addr,
reply_email=reply_email, reply_email=reply_email,
) )
LOG.d("create reverse-alias for %s", contact_email) LOG.d("create reverse-alias for %s", contact_addr)
db.session.commit() db.session.commit()
flash(f"Reverse alias for {contact_email} is created", "success") flash(f"Reverse alias for {contact_addr} is created", "success")
return redirect( return redirect(
url_for( url_for(