Mark Sapiro pushed to branch master at GNU Mailman / Mailman Core
Commits: dae4c7a6 by Mark Sapiro at 2020-08-15T13:40:36-07:00 When a handler rejects or discards a message, stop the pipeline. - - - - - 6c032276 by Mark Sapiro at 2020-08-15T21:55:28+00:00 Merge branch 'pipeline' into 'master' When a handler rejects or discards a message, stop the pipeline. Closes #752 See merge request mailman/mailman!686 - - - - - 3 changed files: - src/mailman/core/pipelines.py - src/mailman/core/tests/test_pipelines.py - src/mailman/docs/NEWS.rst Changes: ===================================== src/mailman/core/pipelines.py ===================================== @@ -52,11 +52,15 @@ def process(mlist, msg, msgdata, pipeline_name='built-in'): vlog.info( '{} discarded by "{}" pipeline handler "{}": {}'.format( message_id, pipeline_name, handler.name, error.message)) + # Stop processing the pipeline. + break except RejectMessage as error: vlog.info( '{} rejected by "{}" pipeline handler "{}": {}'.format( message_id, pipeline_name, handler.name, str(error))) bounce_message(mlist, msg, error) + # Stop processing the pipeline. + break @public ===================================== src/mailman/core/tests/test_pipelines.py ===================================== @@ -22,6 +22,7 @@ import unittest from mailman.app.lifecycle import create_list from mailman.config import config from mailman.core.pipelines import process +from mailman.handlers.to_outgoing import ToOutgoing from mailman.interfaces.handler import IHandler from mailman.interfaces.member import MemberRole from mailman.interfaces.pipeline import ( @@ -62,6 +63,7 @@ class DiscardingPipeline: def __iter__(self): yield DiscardingHandler() + yield ToOutgoing() @implementer(IPipeline) @@ -74,6 +76,7 @@ class RejectingPipeline: def __iter__(self): yield RejectHandler(self.message) + yield ToOutgoing() class TestPostingPipeline(unittest.TestCase): @@ -121,6 +124,8 @@ testing self.assertTrue(line.endswith( '<ant> discarded by "test-discarding" pipeline handler ' '"discarding": by test handler')) + # There should be no outgoing message. + get_queue_messages('out', expected_count=0) def test_rejecting_pipeline(self): # If a handler in the pipeline raises RejectMessage, the post will @@ -142,6 +147,8 @@ testing # The first payload contains the rejection reason. payload = items[0].msg.get_payload(0).get_payload() self.assertEqual(payload, 'by test handler') + # There should be no outgoing message. + get_queue_messages('out', expected_count=0) def test_rejecting_pipeline_without_message(self): # Similar to above, but without a rejection message. @@ -166,6 +173,8 @@ testing # The first payload contains the rejection reason. payload = items[0].msg.get_payload(0).get_payload() self.assertEqual(payload, '[No details are available]') + # There should be no outgoing message. + get_queue_messages('out', expected_count=0) def test_decorate_bulk(self): # Ensure that bulk postings get decorated with the footer. ===================================== src/mailman/docs/NEWS.rst ===================================== @@ -28,6 +28,8 @@ Bugs * Bounce probes can now be sent to a member subscribed as a User. (Closes #739) * A member subscribed as a User can now be unsubscribed. (Closes #734) +* When a handler rejects or discards a message, it won't be delivered or + archived anyway. (Closes #752) Command line ------------ View it on GitLab: https://gitlab.com/mailman/mailman/-/compare/fe80eab28fecda0e7e6f5fdb8b3574bb47b85a23...6c03227657abe8c896a3db75ceacfd7a7f7b64ff -- View it on GitLab: https://gitlab.com/mailman/mailman/-/compare/fe80eab28fecda0e7e6f5fdb8b3574bb47b85a23...6c03227657abe8c896a3db75ceacfd7a7f7b64ff You're receiving this email because of your account on gitlab.com.
_______________________________________________ Mailman-checkins mailing list -- mailman-checkins@python.org To unsubscribe send an email to mailman-checkins-le...@python.org https://mail.python.org/mailman3/lists/mailman-checkins.python.org/ Member address: arch...@jab.org