Source

iredapd / plugins / amavisd_block_blacklisted_senders.py

Diff from to

plugins/amavisd_block_blacklisted_senders.py

 
 
 def restriction(**kwargs):
-    smtpSessionData = kwargs['smtpSessionData']
-    ldapRecipientLdif = kwargs['recipientLdif']
-    # Get sender address.
-    sender = smtpSessionData.get('sender').lower()
+    smtp_session_data = kwargs['smtp_session_data']
+    recipient_ldif = kwargs['recipient_ldif']
+
+    if not 'amavisAccount' in recipient_ldif['objectClass']:
+        return 'DUNNO (Not a amavisdAccount object)'
+
+    sender = smtp_session_data.get('sender').lower()
 
     # Get valid Amavisd sender, sender domain and sub-domain(s).
     # - Sample user: user@sub2.sub1.com.cn
         splited_sender_domain.pop(0)
 
     # Get list of amavisBlacklistedSender.
-    blSenders = set([v.lower() for v in ldapRecipientLdif.get('amavisBlacklistSender', [])])
+    blSenders = set([v.lower() for v in recipient_ldif.get('amavisBlacklistSender', [])])
 
     # Get list of amavisWhitelistSender.
-    wlSenders = set([v.lower() for v in ldapRecipientLdif.get('amavisWhitelistSender', [])])
+    wlSenders = set([v.lower() for v in recipient_ldif.get('amavisWhitelistSender', [])])
 
     logging.debug('Sender: %s' % sender)
     logging.debug('Whitelisted senders: %s' % str(wlSenders))
Tip: Filter by directory path e.g. /media app.js to search for public/media/app.js.
Tip: Use camelCasing e.g. ProjME to search for ProjectModifiedEvent.java.
Tip: Filter by extension type e.g. /repo .js to search for all .js files in the /repo directory.
Tip: Separate your search with spaces e.g. /ssh pom.xml to search for src/ssh/pom.xml.
Tip: Use ↑ and ↓ arrow keys to navigate and return to view the file.
Tip: You can also navigate files with Ctrl+j (next) and Ctrl+k (previous) and view the file with Ctrl+o.
Tip: You can also navigate files with Alt+j (next) and Alt+k (previous) and view the file with Alt+o.