From 926cc2935c8b5e0d4fef7958b72f2c5c87516994 Mon Sep 17 00:00:00 2001 From: Son NK Date: Wed, 22 Jan 2020 14:21:01 +0100 Subject: [PATCH] take into account DISABLE_ALIAS_SUFFIX in /api/alias/options --- app/api/views/alias_options.py | 13 +++++++++---- 1 file changed, 9 insertions(+), 4 deletions(-) diff --git a/app/api/views/alias_options.py b/app/api/views/alias_options.py index c1015028..1d9c7040 100644 --- a/app/api/views/alias_options.py +++ b/app/api/views/alias_options.py @@ -3,7 +3,7 @@ from flask_cors import cross_origin from sqlalchemy import desc from app.api.base import api_bp, verify_api_key -from app.config import ALIAS_DOMAINS +from app.config import ALIAS_DOMAINS, DISABLE_ALIAS_SUFFIX from app.extensions import db from app.log import LOG from app.models import AliasUsedOn, GenEmail, User @@ -71,7 +71,10 @@ def options(): # maybe better to make sure the suffix is never used before # but this is ok as there's a check when creating a new custom alias for domain in ALIAS_DOMAINS: - ret["custom"]["suffixes"].append(f".{random_word()}@{domain}") + if DISABLE_ALIAS_SUFFIX: + ret["custom"]["suffixes"].append(f"@{domain}") + else: + ret["custom"]["suffixes"].append(f".{random_word()}@{domain}") for custom_domain in user.verified_custom_domains(): ret["custom"]["suffixes"].append("@" + custom_domain.domain) @@ -146,9 +149,11 @@ def options_v2(): # maybe better to make sure the suffix is never used before # but this is ok as there's a check when creating a new custom alias - # todo: take into account DISABLE_ALIAS_SUFFIX for domain in ALIAS_DOMAINS: - ret["suffixes"].append(f".{random_word()}@{domain}") + if DISABLE_ALIAS_SUFFIX: + ret["suffixes"].append(f"@{domain}") + else: + ret["suffixes"].append(f".{random_word()}@{domain}") for custom_domain in user.verified_custom_domains(): ret["suffixes"].append("@" + custom_domain.domain)