------------------------------------------------------------
revno: 1518
committer: Mark Sapiro <m...@msapiro.net>
branch nick: 2.1
timestamp: Fri 2015-01-23 15:50:47 -0800
message:
  Implemented the equivalent domains feature for list posting/moderation.
modified:
  Mailman/Defaults.py.in
  Mailman/Gui/Privacy.py
  Mailman/Handlers/Moderate.py
  Mailman/MailList.py
  Mailman/Utils.py
  Mailman/versions.py
  NEWS


--
lp:mailman/2.1
https://code.launchpad.net/~mailman-coders/mailman/2.1

Your team Mailman Checkins is subscribed to branch lp:mailman/2.1.
To unsubscribe from this branch go to 
https://code.launchpad.net/~mailman-coders/mailman/2.1/+edit-subscription
=== modified file 'Mailman/Defaults.py.in'
--- Mailman/Defaults.py.in	2015-01-23 00:09:03 +0000
+++ Mailman/Defaults.py.in	2015-01-23 23:50:47 +0000
@@ -1101,7 +1101,27 @@
 # The total time to spend trying to get an answer to the question.
 DMARC_RESOLVER_LIFETIME = seconds(5)
 
-# What shold happen to non-member posts which are do not match explicit
+# What domains should be considered equivalent when testing list membership
+# for posting/moderation.
+# If two poster addresses with the same local part but
+# different domains are to be considered equivalents for list
+# membership tests, the domains are put here.  The format is
+# one or more groups of equivalent domains.  Within a group,
+# the domains are separated by commas and multiple groups are
+# separated by semicolons. White space is ignored.
+# For example:
+#
+#    'example.com,mail.example.com;mac.com,me.com,icloud.com'
+#
+# In this example, if u...@example.com is a list member,
+# a post from u...@mail.example.com will be treated as if it is
+# from u...@example.com for list membership/moderation purposes,
+# and likewise, if u...@me.com is a list member, posts from
+# u...@mac.com or u...@icloud.com will be treated as if from
+# u...@me.com.
+DEFAULT_EQUIVALENT_DOMAINS = ''
+
+# What should happen to non-member posts which are do not match explicit
 # non-member actions?
 # 0 = Accept
 # 1 = Hold

=== modified file 'Mailman/Gui/Privacy.py'
--- Mailman/Gui/Privacy.py	2015-01-23 00:09:03 +0000
+++ Mailman/Gui/Privacy.py	2015-01-23 23:50:47 +0000
@@ -302,6 +302,33 @@
              be sent to anyone who posts to this list from a domain
              with a DMARC Reject%(quarantine)s Policy.""")),
 
+            ('equivalent_domains', mm_cfg.Text, (10, WIDTH), 1,
+             _("""A 'two dimensional' list of email address domains which are
+               considered equivalent when checking if a post is from a list
+               member."""),
+
+             _("""If two poster addresses with the same local part but
+               different domains are to be considered equivalents for list
+               membership tests, the domains are put here.  The format is
+               one or more groups of equivalent domains.  Within a group,
+               the domains are separated by commas and multiple groups are
+               separated by semicolons. White space is ignored.
+               <p>For example:<pre>
+               example.com,mail.example.com;mac.com,me.com,icloud.com
+               </pre>
+               <p>In this example, if u...@example.com is a list member,
+               a post from u...@mail.example.com will be treated as if it is
+               from u...@example.com for list membership/moderation purposes,
+               and likewise, if u...@me.com is a list member, posts from
+               u...@mac.com or u...@icloud.com will be treated as if from
+               u...@me.com.
+               <p>Note that the poster's address is first tested for list
+               membership, and the equivalent domain addresses are only tested
+               if the poster's address is not that of a member.
+               <p>Also note that moderation of the equivalent domain address
+               will apply to the post, but other options such as 'ack' or
+               'not&nbsp;metoo' will not.""")),
+
             _('Non-member filters'),
 
             ('accept_these_nonmembers', mm_cfg.EmailListEx, (10, WIDTH), 1,

=== modified file 'Mailman/Handlers/Moderate.py'
--- Mailman/Handlers/Moderate.py	2015-01-23 00:09:03 +0000
+++ Mailman/Handlers/Moderate.py	2015-01-23 23:50:47 +0000
@@ -54,6 +54,12 @@
     for sender in msg.get_senders():
         if mlist.isMember(sender):
             break
+        for sender in Utils.check_eq_domains(sender,
+                          mlist.equivalent_domains):
+            if mlist.isMember(sender):
+                break
+        if mlist.isMember(sender):
+            break
     else:
         sender = None
     if sender:

=== modified file 'Mailman/MailList.py'
--- Mailman/MailList.py	2015-01-23 00:09:03 +0000
+++ Mailman/MailList.py	2015-01-23 23:50:47 +0000
@@ -395,6 +395,8 @@
         self.dmarc_quarantine_moderation_action = (
             mm_cfg.DEFAULT_DMARC_QUARANTINE_MODERATION_ACTION)
         self.dmarc_moderation_notice = ''
+        self.equivalent_domains = (
+            mm_cfg.DEFAULT_EQUIVALENT_DOMAINS)
         self.accept_these_nonmembers = []
         self.hold_these_nonmembers = []
         self.reject_these_nonmembers = []

=== modified file 'Mailman/Utils.py'
--- Mailman/Utils.py	2015-01-23 00:09:03 +0000
+++ Mailman/Utils.py	2015-01-23 23:50:47 +0000
@@ -1216,3 +1216,37 @@
 
     return False
 
+
+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',
+    'c'],['1', '2']].  The inner lists are domains which are
+    equivalent in some sense.  The return is an empty list or a list
+    of email addresses equivalent to the first argument.
+    For example, given
+
+    email = 'u...@me.com'
+    domains_list = '''domain1, domain2; mac.com, me.com, icloud.com;
+                   domaina, domainb
+                   '''
+
+    check_eq_domains(email, domains_list) will return
+    ['u...@mac.com', 'u...@icloud.com']
+    """
+    if not domains_list:
+        return []
+    try:
+        local, domain = email.rsplit('@', 1)
+    except ValueError:
+        return []
+    domain = domain.lower()
+    domains_list = re.sub('\s', '', domains_list).lower()
+    domains = domains_list.split(';')
+    domains_list = []
+    for d in domains:
+        domains_list.append(d.split(','))
+    for domains in domains_list:
+        if domain in domains:
+            return [local + '@' + x for x in domains if x != domain]
+    return []
+

=== modified file 'Mailman/versions.py'
--- Mailman/versions.py	2015-01-23 00:09:03 +0000
+++ Mailman/versions.py	2015-01-23 23:50:47 +0000
@@ -407,6 +407,8 @@
     add_only_if_missing('dmarc_quarantine_moderation_action',
                        mm_cfg.DEFAULT_DMARC_QUARANTINE_MODERATION_ACTION)
     add_only_if_missing('dmarc_moderation_notice', '')
+    add_only_if_missing('equivalent_domains', 
+                       mm_cfg.DEFAULT_EQUIVALENT_DOMAINS)
     add_only_if_missing('new_member_options',
                         mm_cfg.DEFAULT_NEW_MEMBER_OPTIONS)
     # Emergency moderation flag

=== modified file 'NEWS'
--- NEWS	2015-01-23 00:09:03 +0000
+++ NEWS	2015-01-23 23:50:47 +0000
@@ -64,6 +64,13 @@
 
   New Features
 
+    - There is a new list attribute equivalent_domains and a
+      DEFAULT_EQUIVALENT_DOMAINS setting to set the default for new lists which
+      in turn defaults to the empty string.  This provides a way to specify one
+      or more groups of domains, e.g., mac.com, me.com, icloud.com, which are
+      considered equivalent for validating list membership for posting and
+      moderation purposes.
+
     - There is a new WEB_HEAD_ADD setting to specify text to be added to the
       <HEAD> section of Mailman's internally generated web pages.  This doesn't
       apply to pages built from templates, but in those cases, custom templates

_______________________________________________
Mailman-checkins mailing list
Mailman-checkins@python.org
Unsubscribe: 
https://mail.python.org/mailman/options/mailman-checkins/archive%40jab.org

Reply via email to