summaryrefslogtreecommitdiff
path: root/src/leap/mx/check_recipient_access.py
diff options
context:
space:
mode:
authorTomas Touceda <chiiph@leap.se>2013-04-25 13:01:01 -0300
committerTomas Touceda <chiiph@leap.se>2013-04-25 13:01:01 -0300
commit92257bdf0b993c67783631a4766d63678f4deb1b (patch)
treebdd25b9cd97e7271658fca37af33425fab67ca19 /src/leap/mx/check_recipient_access.py
parenta0df6b9b8fbf7d4db53bb21f379cb1941d823a5b (diff)
Simplify check recipient access, change the owner field in mail_receiver
Diffstat (limited to 'src/leap/mx/check_recipient_access.py')
-rw-r--r--src/leap/mx/check_recipient_access.py26
1 files changed, 4 insertions, 22 deletions
diff --git a/src/leap/mx/check_recipient_access.py b/src/leap/mx/check_recipient_access.py
index 8d03297..3ea6e91 100644
--- a/src/leap/mx/check_recipient_access.py
+++ b/src/leap/mx/check_recipient_access.py
@@ -22,11 +22,9 @@ Classes for resolving postfix recipient access
import logging
-try:
- from twisted.protocols import postfix
-except ImportError:
- print "This software requires Twisted. Please see the README file"
- print "for instructions on getting required dependencies."
+from twisted.protocols import postfix
+
+from leap.mx.alias_resolver import AliasResolverFactory
logger = logging.getLogger(__name__)
@@ -39,21 +37,5 @@ class CheckRecipientAccess(postfix.PostfixTCPMapServer):
self.sendCode(200)
-class CheckRecipientAccessFactory(postfix.PostfixTCPMapDeferringDictServerFactory):
-
+class CheckRecipientAccessFactory(AliasResolverFactory):
protocol = CheckRecipientAccess
-
- def __init__(self, couchdb, *args, **kwargs):
- postfix.PostfixTCPMapDeferringDictServerFactory.__init__(self, *args, **kwargs)
- self._cdb = couchdb
-
- def get(self, key):
- orig_key = key
- try:
- key = key.split("@")[0]
- key = key.split("+")[0]
- except Exception as e:
- key = orig_key
- logger.exception("%s" % (e,))
- d = self._cdb.queryByLoginOrAlias(key)
- return d