Mark Sapiro pushed to branch master at GNU Mailman / Mailman Core

Commits:
317c0f68 by Nick Wynja at 2019-01-11T15:24:54Z
Introduces explicit_header_only option

Introduce option for not including list address in CC when replying.

Closes #531

- - - - -
2bd6c61d by Mark Sapiro at 2019-01-12T00:34:11Z
Update NEWS.rst
- - - - -
8b45e148 by Mark Sapiro at 2019-01-12T00:36:37Z
Update test_cook_headers.py
- - - - -
240d1479 by Nick Wynja at 2019-01-12T17:00:19Z
Merge branch 'patch-1' into 'master'

Update NEWS.rst

See merge request nickwynja/mailman!1
- - - - -
49389eab by Nick Wynja at 2019-01-12T17:00:36Z
Merge branch 'patch-2' into 'master'

Update test_cook_headers.py

See merge request nickwynja/mailman!2
- - - - -
1e959748 by Mark Sapiro at 2019-01-12T18:10:39Z
Merge branch 'master' into 'master'

Introduces explicit_header_only option

Closes #531

See merge request mailman/mailman!430
- - - - -


5 changed files:

- src/mailman/docs/NEWS.rst
- src/mailman/handlers/cook_headers.py
- src/mailman/handlers/docs/reply-to.rst
- src/mailman/handlers/tests/test_cook_headers.py
- src/mailman/interfaces/mailinglist.py


Changes:

=====================================
src/mailman/docs/NEWS.rst
=====================================
@@ -39,6 +39,8 @@ Other
 * Email commands are now case insensitive.  (Closes #353)
 * Implicit commands sent to -join, -leave and -confirm addresses no longer
   generate a Results email.  (Closes #516)
+* An ``explicit_header_only`` option has been added to Reply-To: munging to
+  avoid putting the list address in Cc:.  (Closes #531)
 
 
 3.2.0 -- "La Villa Strangiato"


=====================================
src/mailman/handlers/cook_headers.py
=====================================
@@ -105,8 +105,10 @@ def process(mlist, msg, msgdata):
             d[lcaddr] = pair
             new.append(pair)
         # List admin wants an explicit Reply-To: added
-        if mlist.reply_goes_to_list is ReplyToMunging.explicit_header:
-            add(parseaddr(mlist.reply_to_address))
+        if (mlist.reply_goes_to_list is ReplyToMunging.explicit_header
+            or mlist.reply_goes_to_list is
+                ReplyToMunging.explicit_header_only):
+                    add(parseaddr(mlist.reply_to_address))
         # If we're not first stripping existing Reply-To: then we need to add
         # the original Reply-To:'s to the list we're building up.  In both
         # cases we'll zap the existing field because RFC 2822 says max one is
@@ -147,10 +149,14 @@ def process(mlist, msg, msgdata):
             d = {}
             for pair in getaddresses(msg.get_all('cc', [])):
                 add(pair)
-            i18ndesc = uheader(mlist, mlist.description, 'Cc')
-            add((str(i18ndesc), mlist.posting_address))
+            if (mlist.reply_goes_to_list is not
+                    ReplyToMunging.explicit_header_only):
+                i18ndesc = uheader(mlist, mlist.description, 'Cc')
+                add((str(i18ndesc), mlist.posting_address))
             del msg['Cc']
-            msg['Cc'] = COMMASPACE.join([formataddr(pair) for pair in new])
+            # Don't add an empty Cc:
+            if new:
+                msg['Cc'] = COMMASPACE.join([formataddr(pair) for pair in new])
 
 
 @public


=====================================
src/mailman/handlers/docs/reply-to.rst
=====================================
@@ -129,3 +129,29 @@ header...
     1
     >>> print(msg['reply-to'])
     my-l...@example.com, bper...@example.com
+
+
+Don't CC List Address in Reply
+==============================
+
+The default behavior of a personalized list is that a reply goes ``To``
+the message sender and the list address is added to ``Cc``.
+
+The list can be configured so that replying to a list message replies only
+to the explicit ``Reply-To`` header and does not include the list address
+in ``Cc``.
+
+    >>> mlist.reply_goes_to_list = ReplyToMunging.explicit_header_only
+    >>> mlist.reply_to_address = 'my-l...@example.com'
+    >>> mlist.first_strip_reply_to = True
+    >>> msg = message_from_string("""\
+    ... From: aper...@example.com
+    ... Reply-To: bper...@example.com
+    ... Cc: cper...@example.com
+    ...
+    ... """)
+    >>> process(mlist, msg, {})
+    >>> print(msg['reply-to'])
+    my-l...@example.com
+    >>> print(msg['cc'])
+    cper...@example.com


=====================================
src/mailman/handlers/tests/test_cook_headers.py
=====================================
@@ -21,7 +21,7 @@ import unittest
 
 from mailman.app.lifecycle import create_list
 from mailman.handlers import cook_headers
-from mailman.interfaces.mailinglist import ReplyToMunging
+from mailman.interfaces.mailinglist import Personalization, ReplyToMunging
 from mailman.interfaces.member import DeliveryMode
 from mailman.testing.helpers import (
     LogFileMark, get_queue_messages, make_digest_messages,
@@ -107,5 +107,33 @@ X-Mailman-Version: X.Y
 Precedence: list
 Reply-To: =?utf-8?b?U29tZSBDb2ZmZWUg4piV?= <a...@example.com>
 
+More things to say.
+""")
+
+    def test_no_list_address_in_cc(self):
+        self._mlist.personalize = Personalization.full
+        self._mlist.reply_goes_to_list = ReplyToMunging.explicit_header_only
+        self._mlist.reply_to_address = 'my-l...@example.com'
+        self._mlist.first_strip_reply_to = True
+        msg = mfs("""\
+From: a...@example.com
+To: a...@example.com
+Reply-To: bper...@example.com
+Cc: cper...@example.com
+Subject: A subject
+X-Mailman-Version: X.Y
+
+More things to say.
+""")
+        cook_headers.process(self._mlist, msg, {})
+        self.assertMultiLineEqual(msg.as_string(), """\
+From: a...@example.com
+To: a...@example.com
+Subject: A subject
+X-Mailman-Version: X.Y
+Precedence: list
+Reply-To: my-l...@example.com
+Cc: cper...@example.com
+
 More things to say.
 """)


=====================================
src/mailman/interfaces/mailinglist.py
=====================================
@@ -71,6 +71,9 @@ class ReplyToMunging(Enum):
     point_to_list = 1
     # An explicit Reply-To header is added
     explicit_header = 2
+    # An explicit Reply-To header is added and
+    # the list address is removed from CC
+    explicit_header_only = 3
 
 
 @public



View it on GitLab: 
https://gitlab.com/mailman/mailman/compare/4246f6d155ff1b4beab5f048110777d1f4977765...1e9597487a199f8b69bb9cf5de33e14ae7ab444e

-- 
View it on GitLab: 
https://gitlab.com/mailman/mailman/compare/4246f6d155ff1b4beab5f048110777d1f4977765...1e9597487a199f8b69bb9cf5de33e14ae7ab444e
You're receiving this email because of your account on gitlab.com.
_______________________________________________
Mailman-checkins mailing list
Mailman-checkins@python.org
Unsubscribe: 
https://mail.python.org/mailman/options/mailman-checkins/archive%40jab.org

Reply via email to