From c6b21fd735a266b7482fdeb59102f1803bf883ff Mon Sep 17 00:00:00 2001 From: Mark Sapiro Date: Thu, 3 Nov 2022 16:28:56 +0000 Subject: [PATCH] The change in !997 was incorrect. It would not allow subscribing any of a user's addresses to a list if the `user` was subscribed. The proper change is to not allow subscribing of a user's preferred address if the `user` is subscribed. This corrects that. It also adds a regression test to insure that subscribing a user's 'other' address succeeds. --- src/mailman/app/subscriptions.py | 2 +- src/mailman/app/tests/test_subscriptions.py | 24 ++++++++++++++++++++++++ src/mailman/docs/NEWS.rst | 6 ++++++ 3 files changed, 31 insertions(+), 1 deletion(-) diff --git a/src/mailman/app/subscriptions.py b/src/mailman/app/subscriptions.py index 37ecc0217..d916da416 100644 --- a/src/mailman/app/subscriptions.py +++ b/src/mailman/app/subscriptions.py @@ -237,7 +237,7 @@ class SubscriptionWorkflow(_SubscriptionWorkflowCommon): assert self.user is not None and self.address is not None, ( 'Insane sanity check results') # Is this subscriber already a member? - if ((self.user.preferred_address is not None and + if ((self.user.preferred_address == self.address and self.mlist.is_subscribed(self.user)) or self.mlist.is_subscribed(self.address)): raise AlreadySubscribedError( diff --git a/src/mailman/app/tests/test_subscriptions.py b/src/mailman/app/tests/test_subscriptions.py index 35f6c22da..dfc52655b 100644 --- a/src/mailman/app/tests/test_subscriptions.py +++ b/src/mailman/app/tests/test_subscriptions.py @@ -961,3 +961,27 @@ approval: items = get_queue_messages('virgin', expected_count=1) self.assertEqual(str(items[0].msg['Subject']), "Vous avez" " été désabonné de la liste de diffusion Test") + + def test_mutltiple_subscriptions_for_one_user(self): + anne = self._user_manager.create_user(self._anne) + set_preferred(anne) + email_2 = self._user_manager.create_address('second@example.com') + anne.link(email_2) + # Subscribe the user first. + workflow = SubscriptionWorkflow( + self._mlist, anne, + pre_verified=True, pre_confirmed=True, pre_approved=True + ) + list(workflow) + # Assert the user was subscribed. + member = self._mlist.regular_members.get_member(self._anne) + self.assertIsNotNone(member) + # Now, try to subscribe the 2nd address of the same user. + workflow = SubscriptionWorkflow( + self._mlist, email_2, + pre_verified=True, pre_confirmed=True, pre_approved=True + ) + list(workflow) + # And assert it succeeded. + member = self._mlist.regular_members.get_member(email_2.email) + self.assertIsNotNone(member) diff --git a/src/mailman/docs/NEWS.rst b/src/mailman/docs/NEWS.rst index 0493c0ecd..4ec20670a 100644 --- a/src/mailman/docs/NEWS.rst +++ b/src/mailman/docs/NEWS.rst @@ -13,6 +13,12 @@ Here is a history of user visible changes to Mailman. 3.3.7 ===== +(2022-xx-xx) + +Bugs fixed +---------- +* The fix for #994 in 3.3.6 blocked too many subscription attempts. This is + now corrected and another test added. .. _news-3.3.6: -- 2.11.4.GIT