From 805e78cad179671bef948c52bec0abf94b5deedb Mon Sep 17 00:00:00 2001 From: Son NK <> Date: Wed, 14 Oct 2020 18:46:05 +0200 Subject: [PATCH] rename email_belongs_to_alias_domains -> email_belongs_to_default_domains --- app/alias_utils.py | 4 ++-- app/email_utils.py | 2 +- email_handler.py | 4 ++-- tests/test_email_utils.py | 10 +++++----- 4 files changed, 10 insertions(+), 10 deletions(-) diff --git a/app/alias_utils.py b/app/alias_utils.py index 39034569..43c2d448 100644 --- a/app/alias_utils.py +++ b/app/alias_utils.py @@ -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 diff --git a/app/email_utils.py b/app/email_utils.py index 07cc37f3..3e899431 100644 --- a/app/email_utils.py +++ b/app/email_utils.py @@ -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): diff --git a/email_handler.py b/email_handler.py index 1b256127..8f8090fd 100644 --- a/email_handler.py +++ b/email_handler.py @@ -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" diff --git a/tests/test_email_utils.py b/tests/test_email_utils.py index 5ced93aa..bceda205 100644 --- a/tests/test_email_utils.py +++ b/tests/test_email_utils.py @@ -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):