diff options
| author | Barry Warsaw | 2017-08-04 01:13:04 +0000 |
|---|---|---|
| committer | Barry Warsaw | 2017-08-04 01:13:04 +0000 |
| commit | 9cdcffbc1189a19bc2963cf3d5c86a3d4f1f24a6 (patch) | |
| tree | f021166b8c82bb02feff82a9360ba61a44b804ee /src/mailman/rules | |
| parent | e6326533b78290514ede917ed1cb95804759a45a (diff) | |
| download | mailman-9cdcffbc1189a19bc2963cf3d5c86a3d4f1f24a6.tar.gz mailman-9cdcffbc1189a19bc2963cf3d5c86a3d4f1f24a6.tar.zst mailman-9cdcffbc1189a19bc2963cf3d5c86a3d4f1f24a6.zip | |
Rename metadata key for clarity
Diffstat (limited to '')
| -rw-r--r-- | src/mailman/rules/dmarc.py | 10 | ||||
| -rw-r--r-- | src/mailman/rules/docs/dmarc-mitigation.rst | 6 | ||||
| -rw-r--r-- | src/mailman/rules/docs/moderation.rst | 18 | ||||
| -rw-r--r-- | src/mailman/rules/moderation.py | 4 | ||||
| -rw-r--r-- | src/mailman/rules/tests/test_moderation.py | 12 |
5 files changed, 25 insertions, 25 deletions
diff --git a/src/mailman/rules/dmarc.py b/src/mailman/rules/dmarc.py index 9f9b11673..2741eb1df 100644 --- a/src/mailman/rules/dmarc.py +++ b/src/mailman/rules/dmarc.py @@ -298,15 +298,15 @@ class DMARCMitigation: if mlist.dmarc_mitigate_action is DMARCMitigateAction.no_mitigation: # Don't bother to check if we're not going to do anything. return False - dn, addr = parseaddr(msg.get('from')) - if maybe_mitigate(mlist, addr): + display_name, address = parseaddr(msg.get('from')) + if maybe_mitigate(mlist, address): # If dmarc_mitigate_action is discard or reject, this rule fires # and jumps to the 'moderation' chain to do the actual discard. # Otherwise, the rule misses but sets a flag for the dmarc handler # to do the appropriate action. msgdata['dmarc'] = True if mlist.dmarc_mitigate_action is DMARCMitigateAction.discard: - msgdata['moderation_action'] = 'discard' + msgdata['dmarc_action'] = 'discard' with _.defer_translation(): # This will be translated at the point of use. msgdata.setdefault('moderation_reasons', []).append( @@ -324,9 +324,9 @@ class DMARCMitigation: 'contact the mailing list owner at ${listowner}.')) msgdata.setdefault('moderation_reasons', []).append( wrap(reason)) - msgdata['moderation_action'] = 'reject' + msgdata['dmarc_action'] = 'reject' else: return False - msgdata['moderation_sender'] = addr + msgdata['moderation_sender'] = address return True return False diff --git a/src/mailman/rules/docs/dmarc-mitigation.rst b/src/mailman/rules/docs/dmarc-mitigation.rst index bee7b3a55..cf7ceeb74 100644 --- a/src/mailman/rules/docs/dmarc-mitigation.rst +++ b/src/mailman/rules/docs/dmarc-mitigation.rst @@ -102,7 +102,7 @@ message. True >>> dump_msgdata(msgdata) dmarc : True - moderation_action : discard + dmarc_action : discard moderation_reasons: ['DMARC moderation'] moderation_sender : aperson@example.biz @@ -121,7 +121,7 @@ We can reject the message with a default reason. True >>> dump_msgdata(msgdata) dmarc : True - moderation_action : reject + dmarc_action : reject moderation_reasons: ['You are not allowed to post to this mailing list... moderation_sender : aperson@example.biz @@ -140,6 +140,6 @@ And, we can reject with a custom message. True >>> dump_msgdata(msgdata) dmarc : True - moderation_action : reject + dmarc_action : reject moderation_reasons: ['A silly reason'] moderation_sender : aperson@example.biz diff --git a/src/mailman/rules/docs/moderation.rst b/src/mailman/rules/docs/moderation.rst index d1cc5fd67..8bdcd2f1a 100644 --- a/src/mailman/rules/docs/moderation.rst +++ b/src/mailman/rules/docs/moderation.rst @@ -60,9 +60,9 @@ the eventual moderation chain. >>> member_rule.check(mlist, member_msg, msgdata) True >>> dump_msgdata(msgdata) - moderation_action : hold - moderation_reasons: ['The message comes from a moderated member'] - moderation_sender : aperson@example.com + member_moderation_action: hold + moderation_reasons : ['The message comes from a moderated member'] + moderation_sender : aperson@example.com Nonmembers @@ -107,9 +107,9 @@ rule matches and the message metadata again carries some useful information. >>> nonmember_rule.check(mlist, nonmember_msg, msgdata) True >>> dump_msgdata(msgdata) - moderation_action : hold - moderation_reasons: ['The message is not from a list member'] - moderation_sender : bperson@example.com + member_moderation_action: hold + moderation_reasons : ['The message is not from a list member'] + moderation_sender : bperson@example.com Of course, the nonmember action can be set to defer the decision, in which case the rule does not match. @@ -161,9 +161,9 @@ nonmember of the list. The rule also matches. >>> nonmember_rule.check(mlist, msg, msgdata) True >>> dump_msgdata(msgdata) - moderation_action : hold - moderation_reasons: ['The message is not from a list member'] - moderation_sender : cperson@example.com + member_moderation_action: hold + moderation_reasons : ['The message is not from a list member'] + moderation_sender : cperson@example.com >>> dump_list(mlist.members.members, key=memberkey) <Member: Anne Person <aperson@example.com> diff --git a/src/mailman/rules/moderation.py b/src/mailman/rules/moderation.py index 7f78d3ce7..26f04d632 100644 --- a/src/mailman/rules/moderation.py +++ b/src/mailman/rules/moderation.py @@ -82,7 +82,7 @@ class MemberModeration: elif action is not None: # We must stringify the moderation action so that it can be # stored in the pending request table. - msgdata['moderation_action'] = action.name + msgdata['member_moderation_action'] = action.name msgdata['moderation_sender'] = sender with _.defer_translation(): # This will be translated at the point of use. @@ -94,7 +94,7 @@ class MemberModeration: def _record_action(msgdata, action, sender, reason): - msgdata['moderation_action'] = action + msgdata['member_moderation_action'] = action msgdata['moderation_sender'] = sender msgdata.setdefault('moderation_reasons', []).append(reason) diff --git a/src/mailman/rules/tests/test_moderation.py b/src/mailman/rules/tests/test_moderation.py index e08bba480..46d848b42 100644 --- a/src/mailman/rules/tests/test_moderation.py +++ b/src/mailman/rules/tests/test_moderation.py @@ -142,9 +142,9 @@ A message body. msgdata = {} result = rule.check(self._mlist, msg, msgdata) self.assertTrue(result, 'NonmemberModeration rule should hit') - self.assertIn('moderation_action', msgdata) + self.assertIn('member_moderation_action', msgdata) self.assertEqual( - msgdata['moderation_action'], action_name, + msgdata['member_moderation_action'], action_name, 'Wrong action for {}: {}'.format(address, action_name)) def test_nonmember_fallback_to_list_defaults(self): @@ -166,7 +166,7 @@ A message body. msgdata = {} result = rule.check(self._mlist, msg, msgdata) self.assertTrue(result) - self.assertEqual(msgdata['moderation_action'], 'hold') + self.assertEqual(msgdata['member_moderation_action'], 'hold') # As a side-effect, Anne has been added as a nonmember with a # moderation action that falls back to the list's default. anne = self._mlist.nonmembers.get_member('anne@example.com') @@ -177,7 +177,7 @@ A message body. # This time, the message should be discarded. result = rule.check(self._mlist, msg, msgdata) self.assertTrue(result) - self.assertEqual(msgdata.get('moderation_action'), 'discard') + self.assertEqual(msgdata.get('member_moderation_action'), 'discard') def test_member_fallback_to_list_defaults(self): # https://gitlab.com/mailman/mailman/issues/189 @@ -201,14 +201,14 @@ A message body. msgdata = {} result = rule.check(self._mlist, msg, msgdata) self.assertTrue(result) - self.assertEqual(msgdata.get('moderation_action'), 'accept') + self.assertEqual(msgdata.get('member_moderation_action'), 'accept') # Then the list's default member action is changed. self._mlist.default_member_action = Action.hold msg.replace_header('Message-ID', '<bee>') # This time, the message is held. result = rule.check(self._mlist, msg, msgdata) self.assertTrue(result) - self.assertEqual(msgdata.get('moderation_action'), 'hold') + self.assertEqual(msgdata.get('member_moderation_action'), 'hold') def test_linked_address_nonmembermoderation_misses(self): # Anne subscribes to a mailing list as a user with her preferred |
