create some random alias creation

This commit is contained in:
Son NK 2019-12-08 16:59:50 +01:00
parent 8b9a158ac2
commit 139fc68bda
3 changed files with 0 additions and 32 deletions

View file

@ -77,7 +77,6 @@ def custom_alias():
full_email,
custom_domain.domain,
)
# todo: add custom_id to GenEmail
gen_email = GenEmail.create(
email=full_email,
user_id=current_user.id,

View file

@ -49,22 +49,6 @@ def index():
"success",
)
elif request.form.get("form-name") == "create-random-email":
can_create_new_random_alias = current_user.can_create_new_random_alias()
if can_create_new_random_alias:
gen_email = GenEmail.create_new_gen_email(user_id=current_user.id)
db.session.commit()
LOG.d("generate new email %s for user %s", gen_email, current_user)
flash(f"Email {gen_email.email} has been created", "success")
session[HIGHLIGHT_GEN_EMAIL_ID] = gen_email.id
else:
flash(
f"You need to upgrade your plan to create new random alias.",
"warning",
)
elif request.form.get("form-name") == "create-custom-email":
if current_user.can_create_new_custom_alias():
return redirect(url_for("dashboard.custom_alias"))

View file

@ -272,21 +272,6 @@ def authorize():
return redirect(construct_url(redirect_uri, redirect_args, fragment))
def create_or_choose_gen_email(user) -> GenEmail:
can_create_new_random_alias = user.can_create_new_random_alias()
if can_create_new_random_alias:
gen_email = GenEmail.create_new_gen_email(user_id=user.id)
db.session.flush()
LOG.debug("generate email %s for user %s", gen_email.email, user)
else: # need to reuse one of the gen emails created
LOG.d("pick a random email for gen emails for user %s", current_user)
gen_emails = GenEmail.filter_by(user_id=current_user.id).all()
gen_email = random.choice(gen_emails)
return gen_email
def construct_url(url, args: Dict[str, str], fragment: bool = False):
for i, (k, v) in enumerate(args.items()):
# make sure to escape v