mirror of
https://github.com/Mailu/Mailu.git
synced 2024-12-14 10:53:30 +02:00
Unsimplify alias precedence handling
As discussed with hoellen on matrix, since postfix indeed supports including the recipient delimiter character in a verbatim alias, we should support so too — and handle its precedence correctly. The clearer and simpler formulation of the precedence-clauses are credit to @hoellen. Thanks!
This commit is contained in:
parent
ac64a75743
commit
10d2601963
@ -260,14 +260,22 @@ class Email(object):
|
|||||||
|
|
||||||
@classmethod
|
@classmethod
|
||||||
def resolve_destination(cls, localpart, domain_name, ignore_forward_keep=False):
|
def resolve_destination(cls, localpart, domain_name, ignore_forward_keep=False):
|
||||||
localpart_maybe_split = localpart
|
localpart_stripped = None
|
||||||
|
stripped_alias = None
|
||||||
|
|
||||||
if os.environ.get('RECIPIENT_DELIMITER') in localpart:
|
if os.environ.get('RECIPIENT_DELIMITER') in localpart:
|
||||||
localpart_maybe_split = localpart.rsplit(os.environ.get('RECIPIENT_DELIMITER'), 1)[0]
|
localpart_stripped = localpart.rsplit(os.environ.get('RECIPIENT_DELIMITER'), 1)[0]
|
||||||
|
|
||||||
alias = Alias.resolve(localpart_maybe_split, domain_name)
|
pure_alias = Alias.resolve(localpart, domain_name)
|
||||||
|
pure_alias_has_wildcard = pure_alias and '%' in pure_alias.email and pure_alias.wildcard
|
||||||
|
stripped_alias = Alias.resolve(localpart_stripped, domain_name)
|
||||||
|
|
||||||
if alias:
|
if pure_alias and not pure_alias_has_wildcard:
|
||||||
return alias.destination
|
return pure_alias.destination
|
||||||
|
elif stripped_alias:
|
||||||
|
return stripped_alias.destination
|
||||||
|
elif pure_alias:
|
||||||
|
return pure_alias.destination
|
||||||
|
|
||||||
user = User.query.get('{}@{}'.format(localpart, domain_name))
|
user = User.query.get('{}@{}'.format(localpart, domain_name))
|
||||||
if not user and localpart_stripped:
|
if not user and localpart_stripped:
|
||||||
|
Loading…
Reference in New Issue
Block a user