mirror of
https://github.com/simple-login/app.git
synced 2024-09-20 15:05:59 +08:00
rename email_belongs_to_alias_domains -> email_belongs_to_default_domains
This commit is contained in:
parent
2d9abe55a4
commit
805e78cad1
|
@ -6,7 +6,7 @@ from app.email_utils import (
|
|||
get_email_domain_part,
|
||||
send_cannot_create_directory_alias,
|
||||
send_cannot_create_domain_alias,
|
||||
email_belongs_to_alias_domains,
|
||||
email_belongs_to_default_domains,
|
||||
)
|
||||
from app.errors import AliasInTrashError
|
||||
from app.extensions import db
|
||||
|
@ -39,7 +39,7 @@ def try_auto_create_directory(address: str) -> Optional[Alias]:
|
|||
Try to create an alias with directory
|
||||
"""
|
||||
# check if alias belongs to a directory, ie having directory/anything@EMAIL_DOMAIN format
|
||||
if email_belongs_to_alias_domains(address):
|
||||
if email_belongs_to_default_domains(address):
|
||||
# if there's no directory separator in the alias, no way to auto-create it
|
||||
if "/" not in address and "+" not in address and "#" not in address:
|
||||
return None
|
||||
|
|
|
@ -369,7 +369,7 @@ def delete_all_headers_except(msg: Message, headers: [str]):
|
|||
del msg._headers[i]
|
||||
|
||||
|
||||
def email_belongs_to_alias_domains(address: str) -> bool:
|
||||
def email_belongs_to_default_domains(address: str) -> bool:
|
||||
"""return True if an email ends with one of the alias domains provided by SimpleLogin"""
|
||||
for domain in ALIAS_DOMAINS:
|
||||
if address.endswith("@" + domain):
|
||||
|
|
|
@ -82,7 +82,7 @@ from app.email_utils import (
|
|||
add_dkim_signature,
|
||||
add_or_replace_header,
|
||||
delete_header,
|
||||
email_belongs_to_alias_domains,
|
||||
email_belongs_to_default_domains,
|
||||
render,
|
||||
get_orig_message_from_bounce,
|
||||
delete_all_headers_except,
|
||||
|
@ -716,7 +716,7 @@ def handle_reply(envelope, msg: Message, rcpt_to: str) -> (bool, str):
|
|||
alias_domain = address[address.find("@") + 1 :]
|
||||
|
||||
# alias must end with one of the ALIAS_DOMAINS or custom-domain
|
||||
if not email_belongs_to_alias_domains(alias.email):
|
||||
if not email_belongs_to_default_domains(alias.email):
|
||||
if not CustomDomain.get_by(domain=alias_domain):
|
||||
return False, "550 SL E5"
|
||||
|
||||
|
|
|
@ -4,7 +4,7 @@ from email.message import EmailMessage
|
|||
from app.config import MAX_ALERT_24H
|
||||
from app.email_utils import (
|
||||
get_email_domain_part,
|
||||
email_belongs_to_alias_domains,
|
||||
email_belongs_to_default_domains,
|
||||
email_domain_can_be_used_as_mailbox,
|
||||
delete_header,
|
||||
add_or_replace_header,
|
||||
|
@ -24,11 +24,11 @@ def test_get_email_domain_part():
|
|||
|
||||
def test_email_belongs_to_alias_domains():
|
||||
# default alias domain
|
||||
assert email_belongs_to_alias_domains("ab@sl.local")
|
||||
assert not email_belongs_to_alias_domains("ab@not-exist.local")
|
||||
assert email_belongs_to_default_domains("ab@sl.local")
|
||||
assert not email_belongs_to_default_domains("ab@not-exist.local")
|
||||
|
||||
assert email_belongs_to_alias_domains("hey@d1.test")
|
||||
assert not email_belongs_to_alias_domains("hey@d3.test")
|
||||
assert email_belongs_to_default_domains("hey@d1.test")
|
||||
assert not email_belongs_to_default_domains("hey@d3.test")
|
||||
|
||||
|
||||
def test_can_be_used_as_personal_email(flask_client):
|
||||
|
|
Loading…
Reference in a new issue