summaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
Diffstat (limited to 'src')
-rw-r--r--src/mailman/app/docs/pipelines.rst32
-rw-r--r--src/mailman/core/pipelines.py1
-rw-r--r--src/mailman/core/tests/__init__.py0
-rw-r--r--src/mailman/core/tests/test_pipelines.py62
-rw-r--r--src/mailman/pipeline/rfc_2369.py19
5 files changed, 105 insertions, 9 deletions
diff --git a/src/mailman/app/docs/pipelines.rst b/src/mailman/app/docs/pipelines.rst
index 599a8087c..bc6f9f0ea 100644
--- a/src/mailman/app/docs/pipelines.rst
+++ b/src/mailman/app/docs/pipelines.rst
@@ -2,12 +2,11 @@
Pipelines
=========
-This runner's purpose in life is to process messages that have been accepted
-for posting, applying any modifications and also sending copies of the message
-to the archives, digests, nntp, and outgoing queues. Pipelines are named and
-consist of a sequence of handlers, each of which is applied in turn. Unlike
-rules and chains, there is no way to stop a pipeline from processing the
-message once it's started.
+Pipelines process messages that have been accepted for posting, applying any
+modifications and also sending copies of the message to the archives, digests,
+NNTP, and outgoing queues. Pipelines are named and consist of a sequence of
+handlers, each of which is applied in turn. Unlike rules and chains, there is
+no way to stop a pipeline from processing the message once it's started.
>>> mlist = create_list('test@example.com')
>>> print mlist.pipeline
@@ -41,11 +40,21 @@ etc.
Subject: [Test] My first post
X-Mailman-Version: ...
Precedence: list
+ List-Id: <test.example.com>
+ X-Message-ID-Hash: 4CMWUN6BHVCMHMDAOSJZ2Q72G5M32MWB
+ List-Post: <mailto:test@example.com>
+ List-Subscribe: <http://lists.example.com/listinfo/test@example.com>,
+ <mailto:test-join@example.com>
+ Archived-At: http://lists.example.com/archives/4CMWUN6BHVCMHMDAOSJZ2Q72G5M32MWB
+ List-Unsubscribe: <http://lists.example.com/listinfo/test@example.com>,
+ <mailto:test-leave@example.com>
+ List-Archive: <http://lists.example.com/archives/test@example.com>
+ List-Help: <mailto:test-request@example.com?subject=help>
<BLANKLINE>
First post!
<BLANKLINE>
-And the message metadata has information about recipients and other stuff.
+The message metadata has information about recipients and other stuff.
However there are currently no recipients for this message.
>>> dump_msgdata(msgdata)
@@ -54,7 +63,8 @@ However there are currently no recipients for this message.
recipients : set([])
stripped_subject: My first post
-And the message is now sitting in various other processing queues.
+After pipeline processing, the message is now sitting in various other
+processing queues.
>>> from mailman.testing.helpers import get_queue_messages
>>> messages = get_queue_messages('archive')
@@ -67,6 +77,8 @@ And the message is now sitting in various other processing queues.
Subject: [Test] My first post
X-Mailman-Version: ...
Precedence: list
+ List-Id: <test.example.com>
+ ...
<BLANKLINE>
First post!
<BLANKLINE>
@@ -97,6 +109,8 @@ This is the message that will actually get delivered to end recipients.
Subject: [Test] My first post
X-Mailman-Version: ...
Precedence: list
+ List-Id: <test.example.com>
+ ...
<BLANKLINE>
First post!
<BLANKLINE>
@@ -122,6 +136,8 @@ There's now one message in the digest mailbox, getting ready to be sent.
Subject: [Test] My first post
X-Mailman-Version: ...
Precedence: list
+ List-Id: <test.example.com>
+ ...
<BLANKLINE>
First post!
<BLANKLINE>
diff --git a/src/mailman/core/pipelines.py b/src/mailman/core/pipelines.py
index 6e439af6f..4e5b1b99e 100644
--- a/src/mailman/core/pipelines.py
+++ b/src/mailman/core/pipelines.py
@@ -91,6 +91,7 @@ class BuiltInPipeline(BasePipeline):
'cleanse',
'cleanse-dkim',
'cook-headers',
+ 'rfc-2369',
'to-digest',
'to-archive',
'to-usenet',
diff --git a/src/mailman/core/tests/__init__.py b/src/mailman/core/tests/__init__.py
new file mode 100644
index 000000000..e69de29bb
--- /dev/null
+++ b/src/mailman/core/tests/__init__.py
diff --git a/src/mailman/core/tests/test_pipelines.py b/src/mailman/core/tests/test_pipelines.py
new file mode 100644
index 000000000..4bf552750
--- /dev/null
+++ b/src/mailman/core/tests/test_pipelines.py
@@ -0,0 +1,62 @@
+# Copyright (C) 2012 by the Free Software Foundation, Inc.
+#
+# This file is part of GNU Mailman.
+#
+# GNU Mailman is free software: you can redistribute it and/or modify it under
+# the terms of the GNU General Public License as published by the Free
+# Software Foundation, either version 3 of the License, or (at your option)
+# any later version.
+#
+# GNU Mailman is distributed in the hope that it will be useful, but WITHOUT
+# ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
+# FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for
+# more details.
+#
+# You should have received a copy of the GNU General Public License along with
+# GNU Mailman. If not, see <http://www.gnu.org/licenses/>.
+
+"""Test the core modification pipelines."""
+
+from __future__ import absolute_import, print_function, unicode_literals
+
+__metaclass__ = type
+__all__ = [
+ ]
+
+
+import unittest
+
+
+from mailman.app.lifecycle import create_list
+from mailman.core.pipelines import process
+from mailman.testing.helpers import (
+ reset_the_world,
+ specialized_message_from_string as mfs)
+from mailman.testing.layers import ConfigLayer
+
+
+
+class TestBuiltinPipeline(unittest.TestCase):
+ """Test various aspects of the built-in pipeline."""
+
+ layer = ConfigLayer
+
+ def setUp(self):
+ self._mlist = create_list('test@example.com')
+
+ def tearDown(self):
+ reset_the_world()
+
+ def test_rfc2369_headers(self):
+ # Ensure that RFC 2369 List-* headers are added.
+ msg = mfs("""\
+From: Anne Person <anne@example.org>
+To: test@example.com
+Subject: a test
+
+testing
+""")
+ msgdata = {}
+ process(self._mlist, msg, msgdata, pipeline_name='built-in')
+ self.assertEqual(msg['list-id'], '<test.example.com>')
+ self.assertEqual(msg['list-post'], '<mailto:test@example.com>')
diff --git a/src/mailman/pipeline/rfc_2369.py b/src/mailman/pipeline/rfc_2369.py
index aa99b5c14..26bfe094c 100644
--- a/src/mailman/pipeline/rfc_2369.py
+++ b/src/mailman/pipeline/rfc_2369.py
@@ -21,13 +21,16 @@ from __future__ import absolute_import, unicode_literals
__metaclass__ = type
__all__ = [
- 'process',
+ 'RFC2369',
]
from email.utils import formataddr
+from zope.interface import implements
from mailman.config import config
+from mailman.core.i18n import _
+from mailman.interfaces.handler import IHandler
from mailman.pipeline.cook_headers import uheader
CONTINUATION = ',\n\t'
@@ -93,3 +96,17 @@ def process(mlist, msg, msgdata):
if len(h) + 2 + len(v) > 78:
v = CONTINUATION.join(v.split(', '))
msg[h] = v
+
+
+
+class RFC2369:
+ """Add the RFC 2369 List-* headers."""
+
+ implements(IHandler)
+
+ name = 'rfc-2369'
+ description = _('Add the RFC 2369 List-* headers.')
+
+ def process(self, mlist, msg, msgdata):
+ """See `IHandler`."""
+ process(mlist, msg, msgdata)