diff options
| author | Aurélien Bompard | 2015-06-16 01:45:44 +0200 |
|---|---|---|
| committer | Aurélien Bompard | 2015-06-17 08:24:22 +0200 |
| commit | fae29c1d5c42ed7571895cb713cfe0ed4214c974 (patch) | |
| tree | 9486d60c09e118920e9fdc19cc67a4c0234e71b1 /src/mailman/rules/moderation.py | |
| parent | 92028c599d76bd8e5c17557464e13c352a8af0f8 (diff) | |
| download | mailman-fae29c1d5c42ed7571895cb713cfe0ed4214c974.tar.gz mailman-fae29c1d5c42ed7571895cb713cfe0ed4214c974.tar.zst mailman-fae29c1d5c42ed7571895cb713cfe0ed4214c974.zip | |
Diffstat (limited to 'src/mailman/rules/moderation.py')
| -rw-r--r-- | src/mailman/rules/moderation.py | 19 |
1 files changed, 17 insertions, 2 deletions
diff --git a/src/mailman/rules/moderation.py b/src/mailman/rules/moderation.py index 0cc0b81c3..d2ca6ef6d 100644 --- a/src/mailman/rules/moderation.py +++ b/src/mailman/rules/moderation.py @@ -23,6 +23,8 @@ __all__ = [ ] +import re + from mailman.core.i18n import _ from mailman.interfaces.action import Action from mailman.interfaces.member import MemberRole @@ -93,8 +95,21 @@ class NonmemberModeration: # Do nonmember moderation check. for sender in msg.senders: nonmember = mlist.nonmembers.get_member(sender) - action = (None if nonmember is None - else nonmember.moderation_action) + assert nonmember is not None, ( + 'Sender not added to the nonmembers: {0}'.format(sender)) + # Check the '*_these_nonmembers' properties first + for action in ('accept', 'hold', 'reject', 'discard'): + checklist = getattr(mlist, '{}_these_nonmembers'.format(action)) + for addr in checklist: + if (addr.startswith('^') and re.match(addr, sender)) \ + or addr == sender: + msgdata['moderation_action'] = action + msgdata['moderation_sender'] = sender + msgdata.setdefault('moderation_reasons', []).append( + 'The sender is in the nonmember {} list'.format( + action)) + return True + action = nonmember.moderation_action if action is Action.defer: # The regular moderation rules apply. return False |
