From 52e9ef3b65b68e306f38d9d88d38334ce876b5e2 Mon Sep 17 00:00:00 2001 From: J08nY Date: Mon, 7 Aug 2017 19:39:11 +0200 Subject: Fix moderation, after mailman/mailman/9cdcffb. --- src/mailman_pgp/chains/default.py | 4 ++-- src/mailman_pgp/chains/moderation.py | 30 ++++++++++++++++++++++++++ src/mailman_pgp/rules/tests/test_signature.py | 2 +- src/mailman_pgp/runners/tests/test_incoming.py | 4 ++-- src/mailman_pgp/utils/moderation.py | 2 +- 5 files changed, 36 insertions(+), 6 deletions(-) create mode 100644 src/mailman_pgp/chains/moderation.py (limited to 'src') diff --git a/src/mailman_pgp/chains/default.py b/src/mailman_pgp/chains/default.py index 7806a6e..de9e091 100644 --- a/src/mailman_pgp/chains/default.py +++ b/src/mailman_pgp/chains/default.py @@ -33,8 +33,8 @@ class PGPChain: description = _('The PGP enabled moderation chain.') _link_descriptions = ( - ('pgp-encryption', LinkAction.jump, 'moderation'), - ('pgp-signature', LinkAction.jump, 'moderation'), + ('pgp-encryption', LinkAction.jump, 'pgp-moderation'), + ('pgp-signature', LinkAction.jump, 'pgp-moderation'), ('pgp-mark', LinkAction.defer, None), ('truth', LinkAction.jump, 'default-posting-chain') ) diff --git a/src/mailman_pgp/chains/moderation.py b/src/mailman_pgp/chains/moderation.py new file mode 100644 index 0000000..f7d438d --- /dev/null +++ b/src/mailman_pgp/chains/moderation.py @@ -0,0 +1,30 @@ +# Copyright (C) 2017 Jan Jancar +# +# This file is a part of the Mailman PGP plugin. +# +# This program 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. +# +# This program 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 +# this program. If not, see . + +"""""" +from mailman.chains.base import JumpChainBase +from mailman.core.i18n import _ +from public import public + + +@public +class PGPModerationChain(JumpChainBase): + name = 'pgp-moderation' + description = _('PGP moderation chain.') + + def jump_to(self, mlist, msg, msgsdata): + return msgsdata['pgp_action'] diff --git a/src/mailman_pgp/rules/tests/test_signature.py b/src/mailman_pgp/rules/tests/test_signature.py index 2dce173..ff9b9c4 100644 --- a/src/mailman_pgp/rules/tests/test_signature.py +++ b/src/mailman_pgp/rules/tests/test_signature.py @@ -74,7 +74,7 @@ class TestPGPSignatureRule(TestCase): 'mime_signed_invalid.eml') def assertAction(self, msgdata, action, reasons): - self.assertEqual(msgdata['moderation_action'], action.name) + self.assertEqual(msgdata['pgp_action'], action.name) self.assertListEqual(msgdata['moderation_reasons'], reasons) def test_has_rule(self): diff --git a/src/mailman_pgp/runners/tests/test_incoming.py b/src/mailman_pgp/runners/tests/test_incoming.py index b03f149..48e9ae4 100644 --- a/src/mailman_pgp/runners/tests/test_incoming.py +++ b/src/mailman_pgp/runners/tests/test_incoming.py @@ -106,7 +106,7 @@ Some text. mm_config.switchboards['in'].enqueue(self.msg_clear, msgdata) self.runner.run() items = get_queue_messages('in_default', expected_count=1) - self.assertEqual(items[0].msgdata['moderation_action'], + self.assertEqual(items[0].msgdata['pgp_action'], Action.hold.name) self.assertEqual(items[0].msgdata['moderation_sender'], self.msg_clear.sender) @@ -181,7 +181,7 @@ To: test@example.com msgdata) self.runner.run() items = get_queue_messages('in_default', expected_count=1) - self.assertEqual(items[0].msgdata['moderation_action'], + self.assertEqual(items[0].msgdata['pgp_action'], Action.reject.name) self.assertEqual(items[0].msgdata['moderation_sender'], msg.sender) diff --git a/src/mailman_pgp/utils/moderation.py b/src/mailman_pgp/utils/moderation.py index 850f885..50cc95f 100644 --- a/src/mailman_pgp/utils/moderation.py +++ b/src/mailman_pgp/utils/moderation.py @@ -30,6 +30,6 @@ def record_action(msg, msgdata, action, sender, reason): :param reason: :return: """ - msgdata['moderation_action'] = action.name + msgdata['pgp_action'] = action.name msgdata['moderation_sender'] = sender msgdata.setdefault('moderation_reasons', []).append(reason) -- cgit v1.2.3-70-g09d2