From b8811f8fc2d9bd27d1963c000ddaf05d951b5bda Mon Sep 17 00:00:00 2001 From: "jimpop@template.hostname" <> Date: Wed, 4 Nov 2015 22:49:05 +0000 Subject: Improvements based on feedback from Mark Sapiro https://code.launchpad.net/~jimpop/mailman/mailman-auto-mod-verbose-members/+merge/276706/comments/699744 --- Mailman/Defaults.py.in | 2 +- Mailman/Handlers/SpamDetect.py | 2 +- Mailman/Utils.py | 8 +++----- Mailman/versions.py | 3 ++- 4 files changed, 7 insertions(+), 8 deletions(-) diff --git a/Mailman/Defaults.py.in b/Mailman/Defaults.py.in index 093ce1c8..80d8694c 100755 --- a/Mailman/Defaults.py.in +++ b/Mailman/Defaults.py.in @@ -1122,7 +1122,7 @@ DMARC_RESOLVER_LIFETIME = seconds(5) # DEFAULT_MEMBER_VERBOSITY_INTERVAL = number of seconds to track posts # DEFAULT_MEMBER_VERBOSITY_THRESHOLD = number of allowed posts per interval (0 to disable). DEFAULT_MEMBER_VERBOSITY_INTERVAL = 300 -DEFAULT_MEMBER_VERBOSITY_THRESHOLD = 5 +DEFAULT_MEMBER_VERBOSITY_THRESHOLD = 0 # What domains should be considered equivalent when testing list membership # for posting/moderation. diff --git a/Mailman/Handlers/SpamDetect.py b/Mailman/Handlers/SpamDetect.py index 6c10bb65..509e1e6e 100644 --- a/Mailman/Handlers/SpamDetect.py +++ b/Mailman/Handlers/SpamDetect.py @@ -123,7 +123,7 @@ error, contact the mailing list owner at %(listowner)s.""")) elif mlist.dmarc_moderation_action == 4: raise Errors.DiscardMessage - if Utils.IsVerboseMember(mlist, addr): + if mlist.member_verbosity_threshold > 0 and Utils.IsVerboseMember(mlist, addr): mlist.setMemberOption(addr, mm_cfg.Moderate, 1) syslog('vette', '%s: Automatically Moderated %s for verbose postings.', mlist.real_name, addr) diff --git a/Mailman/Utils.py b/Mailman/Utils.py index a4eb05da..70ef34e8 100644 --- a/Mailman/Utils.py +++ b/Mailman/Utils.py @@ -1250,21 +1250,19 @@ def IsDMARCProhibited(mlist, email): recentMemberPostings = {}; def IsVerboseMember(mlist, email): - threshold = 5 if mlist.member_verbosity_threshold is None else mlist.member_verbosity_threshold - if threshold == 0: + if mlist.member_verbosity_threshold == 0: return False - interval = 5 if mlist.member_verbosity_interval is None else mlist.member_verbosity_interval email = email.lower() t = time.time() recentMemberPostings.setdefault(email,[]).append(t) for t in recentMemberPostings[email]: - if t < time.time() - float(interval): + if t < time.time() - float(mlist.member_verbosity_interval): recentMemberPostings[email].remove(t) - return len(recentMemberPostings[email]) >= threshold + return len(recentMemberPostings[email]) >= mlist.member_verbosity_threshold def check_eq_domains(email, domains_list): diff --git a/Mailman/versions.py b/Mailman/versions.py index d1f06543..d13be94f 100755 --- a/Mailman/versions.py +++ b/Mailman/versions.py @@ -497,7 +497,8 @@ def NewVars(l): add_only_if_missing('dmarc_moderation_notice', '') add_only_if_missing('dmarc_wrapped_message_text', mm_cfg.DEFAULT_DMARC_WRAPPED_MESSAGE_TEXT) - add_only_if_missing('member_verbosity_threshold', 0) + add_only_if_missing('member_verbosity_threshold', + mm_cfg.DEFAULT_MEMBER_VERBOSITY_THRESHOLD) add_only_if_missing('member_verbosity_interval', mm_cfg.DEFAULT_MEMBER_VERBOSITY_INTERVAL) add_only_if_missing('equivalent_domains', -- cgit v1.2.3