Mark Sapiro pushed to branch master at GNU Mailman / Mailman Core


Commits:
40dd0a4d by Mark Sapiro at 2020-12-08T21:46:45-08:00
Handle a bounce for a non-existent list.

- - - - -
b100cd2b by Mark Sapiro at 2020-12-09T06:26:27+00:00
Merge branch 'bounce' into 'master'

Handle a bounce for a non-existent list.

Closes #799

See merge request mailman/mailman!743
- - - - -


3 changed files:

- src/mailman/docs/NEWS.rst
- src/mailman/model/bounce.py
- src/mailman/model/tests/test_bounce.py


Changes:

=====================================
src/mailman/docs/NEWS.rst
=====================================
@@ -27,6 +27,7 @@ Bugs
   parent directory present.  (Closes #699)
 * Fixed an issue where content filtering can throw UnicodeEncodeError when
   converting HTML to plain text.  (Closes #798)
+* A bounce for a non-existent list is now handled.  (Closes #799)
 
 New Features
 ------------


=====================================
src/mailman/model/bounce.py
=====================================
@@ -124,6 +124,13 @@ class BounceProcessor:
         """See `IBounceProcessor`."""
         list_manager = getUtility(IListManager)
         mlist = list_manager.get(event.list_id)
+        if mlist is None:
+            # List was removed before the bounce is processed.
+            event.processed = True
+            # This needs an explicit commit because of the raise.
+            config.db.commit()
+            raise InvalidBounceEvent(
+                'Bounce for non-existent list {}'.format(event.list_id))
         member = mlist.members.get_member(event.email)
         if member is None:
             event.processed = True


=====================================
src/mailman/model/tests/test_bounce.py
=====================================
@@ -20,7 +20,7 @@
 import unittest
 
 from datetime import datetime, timedelta
-from mailman.app.lifecycle import create_list
+from mailman.app.lifecycle import create_list, remove_list
 from mailman.database.transaction import transaction
 from mailman.interfaces.bounce import (
     BounceContext, IBounceProcessor, InvalidBounceEvent)
@@ -138,6 +138,18 @@ Message-Id: <first>
         # Also, the delivery should be unset, the default.
         self.assertIsNone(member.preferences.delivery_status)
 
+        # Now create another event for Anne.
+        self._subscribe_and_add_bounce_event('a...@example.com', create=False,
+                                             subscribe=False)
+        # Now delete the list and process the bounce for the non-existent list.
+        remove_list(self._mlist)
+        events = list(self._processor.unprocessed)
+        self.assertEqual(len(events), 1)
+        # If the MailingList has been deleted, an InvalidBounceEvent exception
+        # is raised.
+        with self.assertRaises(InvalidBounceEvent):
+            self._processor.process_event(events[0])
+
     def test_bounce_score_increases_once_everyday(self):
         # Test only the bounce events more than a day apart can increase the
         # bounce score of a member.



View it on GitLab: 
https://gitlab.com/mailman/mailman/-/compare/45edbcb884ac9198d42f06833ea381585a72b68d...b100cd2be28ad55fe1ad7d9d12775a0ad4a3b4e9

-- 
View it on GitLab: 
https://gitlab.com/mailman/mailman/-/compare/45edbcb884ac9198d42f06833ea381585a72b68d...b100cd2be28ad55fe1ad7d9d12775a0ad4a3b4e9
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

Reply via email to