Commit 2a2a77f3 authored by f00wl's avatar f00wl 🦉
Browse files

use alias delegation (hiboo)

parent 6518ef19
......@@ -133,6 +133,7 @@ class Domain(Base):
max_aliases = db.Column(db.Integer, nullable=False, default=-1)
max_quota_bytes = db.Column(db.BigInteger(), nullable=False, default=0)
signup_enabled = db.Column(db.Boolean(), nullable=False, default=False)
alias_delegation_api = db.Column(db.String(255))
@property
def dkim_key(self):
......@@ -165,6 +166,10 @@ class Domain(Base):
else:
return False
def delegate_alias(self, localpart):
req = requests.get(self.alias_delegation_api.format(localpart))
return req.json() if req.status_code == 200 else []
def check_mx(self):
try:
hostnames = app.config['HOSTNAMES'].split(',')
......@@ -273,6 +278,9 @@ class Email(object):
if os.environ.get('RECIPIENT_DELIMITER') in localpart:
localpart_stripped = localpart.rsplit(os.environ.get('RECIPIENT_DELIMITER'), 1)[0]
if domain and domain.alias_delegation_api:
return domain.delegate_alias(localpart)
user = User.query.get('{}@{}'.format(localpart, domain_name))
if not user and localpart_stripped:
user = User.query.get('{}@{}'.format(localpart_stripped, domain_name))
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment