diff --git a/app/alias_utils.py b/app/alias_utils.py index f8a9e197..47851f8b 100644 --- a/app/alias_utils.py +++ b/app/alias_utils.py @@ -569,5 +569,4 @@ def get_alias_recipient_name(alias: Alias) -> AliasRecipientName: name=sl_formataddr((alias.custom_domain.name, alias.email)), message=f"Put domain default alias name {alias.custom_domain.name} in from header", ) - else: - return AliasRecipientName(name=alias.email) + return AliasRecipientName(name=alias.email) diff --git a/tests/test_alias_utils.py b/tests/test_alias_utils.py index 23839c3a..507b507a 100644 --- a/tests/test_alias_utils.py +++ b/tests/test_alias_utils.py @@ -184,6 +184,25 @@ def test_get_alias_recipient_alias_with_name_and_custom_domain_name(): assert res.name == f"{alias.name} <{alias.email}>" +def test_get_alias_recipient_alias_without_name_and_custom_domain_without_name(): + user = create_new_user() + custom_domain = CustomDomain.create( + user_id=user.id, + domain=random_domain(), + verified=True, + ) + alias = Alias.create( + user_id=user.id, + email=random_email(), + mailbox_id=user.default_mailbox_id, + custom_domain_id=custom_domain.id, + commit=True, + ) + res = get_alias_recipient_name(alias) + assert res.message is None + assert res.name == alias.email + + def test_get_alias_recipient_alias_without_name_and_custom_domain_name(): user = create_new_user() custom_domain = CustomDomain.create(