take into account DISABLE_ALIAS_SUFFIX in /api/alias/options
This commit is contained in:
parent
0c2b2ce60e
commit
926cc2935c
|
@ -3,7 +3,7 @@ from flask_cors import cross_origin
|
||||||
from sqlalchemy import desc
|
from sqlalchemy import desc
|
||||||
|
|
||||||
from app.api.base import api_bp, verify_api_key
|
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.extensions import db
|
||||||
from app.log import LOG
|
from app.log import LOG
|
||||||
from app.models import AliasUsedOn, GenEmail, User
|
from app.models import AliasUsedOn, GenEmail, User
|
||||||
|
@ -71,7 +71,10 @@ def options():
|
||||||
# maybe better to make sure the suffix is never used before
|
# 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
|
# but this is ok as there's a check when creating a new custom alias
|
||||||
for domain in ALIAS_DOMAINS:
|
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():
|
for custom_domain in user.verified_custom_domains():
|
||||||
ret["custom"]["suffixes"].append("@" + custom_domain.domain)
|
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
|
# 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
|
# 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:
|
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():
|
for custom_domain in user.verified_custom_domains():
|
||||||
ret["suffixes"].append("@" + custom_domain.domain)
|
ret["suffixes"].append("@" + custom_domain.domain)
|
||||||
|
|
Loading…
Reference in a new issue