aboutsummaryrefslogtreecommitdiffstats
path: root/Mailman/Utils.py
diff options
context:
space:
mode:
authorMark Sapiro <mark@msapiro.net>2016-01-18 15:56:58 -0800
committerMark Sapiro <mark@msapiro.net>2016-01-18 15:56:58 -0800
commit6d73b41100a69702df03b0f4700cbb36492bea87 (patch)
treedf98d8cc76504b9733680f8d9640170ba27045f8 /Mailman/Utils.py
parent98802661f4d1b54d05bf8bbfbf952e300ec96f7d (diff)
parentb8811f8fc2d9bd27d1963c000ddaf05d951b5bda (diff)
downloadmailman2-6d73b41100a69702df03b0f4700cbb36492bea87.tar.gz
mailman2-6d73b41100a69702df03b0f4700cbb36492bea87.tar.xz
mailman2-6d73b41100a69702df03b0f4700cbb36492bea87.zip
Merged and tweaked Jim P's mailman-auto-mod-verbose-members branch.
Diffstat (limited to '')
-rw-r--r--Mailman/Utils.py49
1 files changed, 48 insertions, 1 deletions
diff --git a/Mailman/Utils.py b/Mailman/Utils.py
index f22e45b4..2404c445 100644
--- a/Mailman/Utils.py
+++ b/Mailman/Utils.py
@@ -1,4 +1,4 @@
-# Copyright (C) 1998-2015 by the Free Software Foundation, Inc.
+# Copyright (C) 1998-2016 by the Free Software Foundation, Inc.
#
# This program is free software; you can redistribute it and/or
# modify it under the terms of the GNU General Public License
@@ -1246,6 +1246,53 @@ def IsDMARCProhibited(mlist, email):
return False
+# Check a known list in order to auto-moderate verbose members
+# dictionary to remember recent posts.
+recentMemberPostings = {}
+# counter of times through
+clean_count = 0
+def IsVerboseMember(mlist, email):
+ """For lists that request it, we keep track of recent posts by address.
+A message from an address to a list, if the list requests it, is remembered
+for a specified time whether or not the address is a list member, and if the
+address is a member and the member is over the threshold for the list, that
+fact is returned."""
+
+ global clean_count
+
+ if mlist.member_verbosity_threshold == 0:
+ return False
+
+ email = email.lower()
+
+ now = time.time()
+ recentMemberPostings.setdefault(email,[]).append(now +
+ float(mlist.member_verbosity_interval)
+ )
+ x = range(len(recentMemberPostings[email]))
+ x.reverse()
+ for i in x:
+ if recentMemberPostings[email][i] < now:
+ del recentMemberPostings[email][i]
+
+ clean_count += 1
+ if clean_count >= mm_cfg.VERBOSE_CLEAN_LIMIT:
+ clean_count = 0
+ for addr in recentMemberPostings.keys():
+ x = range(len(recentMemberPostings[addr]))
+ x.reverse()
+ for i in x:
+ if recentMemberPostings[addr][i] < now:
+ del recentMemberPostings[addr][i]
+ if not recentMemberPostings[addr]:
+ del recentMemberPostings[addr]
+ if not mlist.isMember(email):
+ return False
+ return (len(recentMemberPostings.get(email, [])) >=
+ mlist.member_verbosity_threshold
+ )
+
+
def check_eq_domains(email, domains_list):
"""The arguments are an email address and a string representing a
list of lists in a form like 'a,b,c;1,2' representing [['a', 'b',