From 79768c09f62b6afe20fd05041147d086a48a1845 Mon Sep 17 00:00:00 2001 From: hoellen Date: Sun, 9 Dec 2018 19:49:23 +0100 Subject: [PATCH 1/2] fix alias matching behaviour --- core/admin/mailu/models.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/core/admin/mailu/models.py b/core/admin/mailu/models.py index 18e995bf..1463af8e 100644 --- a/core/admin/mailu/models.py +++ b/core/admin/mailu/models.py @@ -426,7 +426,7 @@ class Alias(Base, Email): ) ) ) - ).first() + ).order_by(sqlalchemy.func.char_length(cls.localpart).desc()).first() class Token(Base): From 8fe9e695f3abd2422271b7c72a40c2d59366ed0f Mon Sep 17 00:00:00 2001 From: hoellen Date: Mon, 10 Dec 2018 08:40:10 +0100 Subject: [PATCH 2/2] prefer non-wildcard aliases over wildcard aliases --- core/admin/mailu/models.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/core/admin/mailu/models.py b/core/admin/mailu/models.py index 1463af8e..a3fc15a4 100644 --- a/core/admin/mailu/models.py +++ b/core/admin/mailu/models.py @@ -426,7 +426,7 @@ class Alias(Base, Email): ) ) ) - ).order_by(sqlalchemy.func.char_length(cls.localpart).desc()).first() + ).order_by(cls.wildcard, sqlalchemy.func.char_length(cls.localpart).desc()).first() class Token(Base):