summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorAurélien Bompard2016-09-02 01:07:36 +0200
committerBarry Warsaw2016-11-25 11:22:07 -0500
commitcecb66d21dbe523ae516e1c30038084190f284b1 (patch)
treed7ac9272d6bec4a1393297184eebabd67d22085a
parent2691956ab9a5eb6de046b067e3dfb7150ade5853 (diff)
downloadmailman-cecb66d21dbe523ae516e1c30038084190f284b1.tar.gz
mailman-cecb66d21dbe523ae516e1c30038084190f284b1.tar.zst
mailman-cecb66d21dbe523ae516e1c30038084190f284b1.zip
-rw-r--r--src/mailman/chains/hold.py3
-rw-r--r--src/mailman/chains/tests/test_hold.py8
-rw-r--r--src/mailman/docs/NEWS.rst2
3 files changed, 12 insertions, 1 deletions
diff --git a/src/mailman/chains/hold.py b/src/mailman/chains/hold.py
index f111aee3c..075191704 100644
--- a/src/mailman/chains/hold.py
+++ b/src/mailman/chains/hold.py
@@ -142,8 +142,9 @@ class HoldChain(TerminalChainBase):
rule_misses = msgdata.get('rule_misses')
if rule_misses:
msg['X-Mailman-Rule-Misses'] = SEMISPACE.join(rule_misses)
+ reasons = msgdata.get('moderation_reasons', ['N/A'])
# Hold the message by adding it to the list's request database.
- request_id = hold_message(mlist, msg, msgdata, None)
+ request_id = hold_message(mlist, msg, msgdata, SEMISPACE.join(reasons))
# Calculate a confirmation token to send to the author of the
# message.
pendable = HeldMessagePendable(id=request_id)
diff --git a/src/mailman/chains/tests/test_hold.py b/src/mailman/chains/tests/test_hold.py
index 13dd1b40e..fc8b8fd3b 100644
--- a/src/mailman/chains/tests/test_hold.py
+++ b/src/mailman/chains/tests/test_hold.py
@@ -26,6 +26,7 @@ from mailman.core.chains import process as process_chain
from mailman.interfaces.autorespond import IAutoResponseSet, Response
from mailman.interfaces.member import MemberRole
from mailman.interfaces.messages import IMessageStore
+from mailman.interfaces.requests import IListRequests, RequestType
from mailman.interfaces.usermanager import IUserManager
from mailman.testing.helpers import (
LogFileMark, configuration, get_queue_messages, set_preferred,
@@ -130,6 +131,13 @@ A message body.
logged = logfile.read()
self.assertIn('TEST-REASON-1', logged)
self.assertIn('TEST-REASON-2', logged)
+ # Check the reason passed to hold_message().
+ requests = IListRequests(self._mlist)
+ self.assertEqual(requests.count_of(RequestType.held_message), 1)
+ request = requests.of_type(RequestType.held_message)[0]
+ key, data = requests.get_request(request.id)
+ self.assertEqual(
+ data.get('_mod_reason'), 'TEST-REASON-1; TEST-REASON-2')
def test_hold_chain_charset(self):
# Issue #144 - UnicodeEncodeError in the hold chain.
diff --git a/src/mailman/docs/NEWS.rst b/src/mailman/docs/NEWS.rst
index 80cadd1b7..db65e9c69 100644
--- a/src/mailman/docs/NEWS.rst
+++ b/src/mailman/docs/NEWS.rst
@@ -99,6 +99,8 @@ Bugs
Bompard. (Closes: #259)
* Messages sent to the list's moderators now include the actual recipient
addresses. Given by Tom Briles. (Closes: #68)
+ * Transmit the moderation reason and expose it in the REST API as the
+ ``reason`` attribute. Given by Aurélien Bompard.
Configuration
-------------