summaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
authorMark Sapiro2016-05-14 12:15:14 -0700
committerGitLab2016-05-15 17:01:00 +0000
commitbc6e2551c997b86ac4ccf04169e7649c0591fbea (patch)
treeb3863be7c96d3c9ceadcc674ba75977bba8e0b9f /src
parent8909417d7c2b1b6fe528de66ad4957dc788759e8 (diff)
downloadmailman-bc6e2551c997b86ac4ccf04169e7649c0591fbea.tar.gz
mailman-bc6e2551c997b86ac4ccf04169e7649c0591fbea.tar.zst
mailman-bc6e2551c997b86ac4ccf04169e7649c0591fbea.zip
Diffstat (limited to 'src')
-rw-r--r--src/mailman/runners/digest.py11
-rw-r--r--src/mailman/runners/docs/digester.rst8
-rw-r--r--src/mailman/runners/tests/test_digest.py36
3 files changed, 39 insertions, 16 deletions
diff --git a/src/mailman/runners/digest.py b/src/mailman/runners/digest.py
index f35b42b9a..16a97eb73 100644
--- a/src/mailman/runners/digest.py
+++ b/src/mailman/runners/digest.py
@@ -55,6 +55,7 @@ class Digester:
self._charset,
header_name='Subject')
self._message = self._make_message()
+ self._digest_part = self._make_digest_part()
self._message['From'] = mlist.request_address
self._message['Subject'] = self._subject
self._message['To'] = mlist.posting_address
@@ -161,6 +162,9 @@ class MIMEDigester(Digester):
def _make_message(self):
return MultipartDigestMessage('mixed')
+ def _make_digest_part(self):
+ return MultipartDigestMessage('digest')
+
def add_toc(self, count):
"""Add the table of contents."""
toc_text = self._toc.getvalue()
@@ -177,10 +181,11 @@ class MIMEDigester(Digester):
"""Add the message to the digest."""
# Make a copy of the message object, since the RFC 1153 processing
# scrubs out attachments.
- self._message.attach(MIMEMessage(deepcopy(msg)))
+ self._digest_part.attach(MIMEMessage(deepcopy(msg)))
def finish(self):
"""Finish up the digest, producing the email-ready copy."""
+ self._message.attach(self._digest_part)
if self._mlist.digest_footer_uri is not None:
try:
footer_text = decorate(
@@ -224,6 +229,10 @@ class RFC1153Digester(Digester):
def _make_message(self):
return Message()
+ def _make_digest_part(self):
+ """Not actually used here but referenced in super().__init__()."""
+ return self._message
+
def add_toc(self, count):
"""Add the table of contents."""
print(self._toc.getvalue(), file=self._text)
diff --git a/src/mailman/runners/docs/digester.rst b/src/mailman/runners/docs/digester.rst
index 00deb0d4a..c5b1a0e6e 100644
--- a/src/mailman/runners/docs/digester.rst
+++ b/src/mailman/runners/docs/digester.rst
@@ -149,7 +149,6 @@ The MIME digest has lots of good stuff, all contained in the multipart.
<BLANKLINE>
When replying, please edit your Subject line so it is more specific
than "Re: Contents of Test digest..."
- <BLANKLINE>
--===============...==
Content-Type: text/plain; charset="us-ascii"
MIME-Version: 1.0
@@ -164,6 +163,10 @@ The MIME digest has lots of good stuff, all contained in the multipart.
4. Test message 4 (aperson@example.com)
<BLANKLINE>
--===============...==
+ Content-Type: multipart/digest; boundary="===============...=="
+ MIME-Version: 1.0
+ <BLANKLINE>
+ --===============...==
Content-Type: message/rfc822
MIME-Version: 1.0
<BLANKLINE>
@@ -207,6 +210,8 @@ The MIME digest has lots of good stuff, all contained in the multipart.
<BLANKLINE>
Here is message 4
<BLANKLINE>
+ --===============...==--
+ <BLANKLINE>
--===============...==
Content-Type: text/plain; charset="us-ascii"
MIME-Version: 1.0
@@ -219,6 +224,7 @@ The MIME digest has lots of good stuff, all contained in the multipart.
http://lists.example.com/listinfo/test@example.com
<BLANKLINE>
--===============...==--
+ <BLANKLINE>
The RFC 1153 contains the digest in a single plain text message.
diff --git a/src/mailman/runners/tests/test_digest.py b/src/mailman/runners/tests/test_digest.py
index f767f78d4..4d9429c55 100644
--- a/src/mailman/runners/tests/test_digest.py
+++ b/src/mailman/runners/tests/test_digest.py
@@ -138,19 +138,21 @@ Here is message $i
multipart/mixed
text/plain
text/plain
- message/rfc822
- text/plain
- message/rfc822
- text/plain
- message/rfc822
- text/plain
- message/rfc822
- text/plain
+ multipart/digest
+ message/rfc822
+ text/plain
+ message/rfc822
+ text/plain
+ message/rfc822
+ text/plain
+ message/rfc822
+ text/plain
text/plain
""")
def test_issue141(self):
# Currently DigestMode.summary_digests are equivalent to mime_digests.
+ # This also tests issue 234.
self._mlist.send_welcome_message = False
bart = subscribe(self._mlist, 'Bart')
bart.preferences.delivery_mode = DeliveryMode.summary_digests
@@ -168,13 +170,15 @@ multipart/mixed
multipart/mixed
text/plain
text/plain
- message/rfc822
- text/plain
+ multipart/digest
+ message/rfc822
+ text/plain
text/plain
""")
def test_issue141_one_last_digest(self):
# Currently DigestMode.summary_digests are equivalent to mime_digests.
+ # Also tests issue 234.
self._mlist.send_welcome_message = False
bart = subscribe(self._mlist, 'Bart')
self._mlist.send_one_last_digest_to(
@@ -193,8 +197,9 @@ multipart/mixed
multipart/mixed
text/plain
text/plain
- message/rfc822
- text/plain
+ multipart/digest
+ message/rfc822
+ text/plain
text/plain
""")
@@ -261,10 +266,13 @@ Content-Transfer-Encoding: 7bit
"Today's Topics (1 messages)")
toc = mime.get_payload(1).get_payload(decode=True).decode('utf-8')
self.assertMultiLineEqual(toc.splitlines()[0], 'Thèmes du jour :')
- # The third subpart contains the posted message in Japanese.
+ # The third subpart is a multipart/digest part and its first subpart
+ # contains the posted message in Japanese.
self.assertEqual(mime.get_payload(2).get_content_type(),
+ 'multipart/digest')
+ self.assertEqual(mime.get_payload(2).get_payload(0).get_content_type(),
'message/rfc822')
- post = mime.get_payload(2).get_payload(0)
+ post = mime.get_payload(2).get_payload(0).get_payload(0)
self.assertEqual(post['subject'], '=?iso-2022-jp?b?GyRCMGxIVhsoQg==?=')
# Compare the bytes so that this module doesn't contain string
# literals in multiple incompatible character sets.