You've already forked Mailu
mirror of
https://github.com/Mailu/Mailu.git
synced 2025-07-13 01:20:28 +02:00
Reverse the resolution order of user and alias
Since it’s common for wildcard~ish systems to prefer concrete objects over wildcards, and aliases can be broad-wildcards (think catchall, %@xxx.tld), it may be more intuitive for users that user-names rank higher than aliases. This makes it impossible for user-names to be unreachable, since they can be completely overridden by a catchall otherwise. This changes default behavior, and is not configurable. closes #815
This commit is contained in:
@ -266,16 +266,6 @@ class Email(object):
|
||||
if os.environ.get('RECIPIENT_DELIMITER') in localpart:
|
||||
localpart_stripped = localpart.rsplit(os.environ.get('RECIPIENT_DELIMITER'), 1)[0]
|
||||
|
||||
pure_alias = Alias.resolve(localpart, domain_name)
|
||||
stripped_alias = Alias.resolve(localpart_stripped, domain_name)
|
||||
|
||||
if pure_alias and not pure_alias.wildcard:
|
||||
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))
|
||||
if not user and localpart_stripped:
|
||||
user = User.query.get('{}@{}'.format(localpart_stripped, domain_name))
|
||||
@ -288,6 +278,16 @@ class Email(object):
|
||||
destination = [user.email]
|
||||
return destination
|
||||
|
||||
pure_alias = Alias.resolve(localpart, domain_name)
|
||||
stripped_alias = Alias.resolve(localpart_stripped, domain_name)
|
||||
|
||||
if pure_alias and not pure_alias.wildcard:
|
||||
return pure_alias.destination
|
||||
elif stripped_alias:
|
||||
return stripped_alias.destination
|
||||
elif pure_alias:
|
||||
return pure_alias.destination
|
||||
|
||||
def __str__(self):
|
||||
return self.email
|
||||
|
||||
|
Reference in New Issue
Block a user