diff options
| -rw-r--r-- | src/mailman/app/subscriptions.py | 2 | ||||
| -rw-r--r-- | src/mailman/app/tests/test_subscriptions.py | 4 | ||||
| -rw-r--r-- | src/mailman/commands/docs/membership.rst | 7 | ||||
| -rw-r--r-- | src/mailman/commands/eml_membership.py | 12 | ||||
| -rw-r--r-- | src/mailman/interfaces/mailinglist.py | 3 | ||||
| -rw-r--r-- | src/mailman/runners/tests/test_leave.py | 2 |
6 files changed, 20 insertions, 10 deletions
diff --git a/src/mailman/app/subscriptions.py b/src/mailman/app/subscriptions.py index cfd1b59a7..49a83c293 100644 --- a/src/mailman/app/subscriptions.py +++ b/src/mailman/app/subscriptions.py @@ -577,7 +577,7 @@ class BaseSubscriptionManager: with flush(): getUtility(IPendings).confirm(token) getUtility(IWorkflowStateManager).discard( - self.WORKFLOW_TYPE.name, token) + self._get_workflow().name, token) @public diff --git a/src/mailman/app/tests/test_subscriptions.py b/src/mailman/app/tests/test_subscriptions.py index 6a3a1aa77..42b60b552 100644 --- a/src/mailman/app/tests/test_subscriptions.py +++ b/src/mailman/app/tests/test_subscriptions.py @@ -286,7 +286,7 @@ class TestSubscriptionWorkflow(unittest.TestCase): def test_moderation_checks_approval_required(self): # The moderator must approve the subscription. self._mlist.subscription_policy = SubscriptionPolicy.moderate - anne = self._user_manager.create_address(self._anne) + anne = self._user_manager.create_address(self._anne, pre_verified=True) workflow = SubscriptionWorkflow(self._mlist, anne) workflow.run_thru('moderation_checks') with patch.object(workflow, '_step_get_moderator_approval') as step: @@ -299,7 +299,7 @@ class TestSubscriptionWorkflow(unittest.TestCase): # confirmations or approvals. self._mlist.subscription_policy = SubscriptionPolicy.open anne = self._user_manager.create_address(self._anne) - workflow = SubscriptionWorkflow(self._mlist, anne) + workflow = SubscriptionWorkflow(self._mlist, anne, pre_verified=True) # Consume the entire state machine. list(workflow) # Anne is now a member of the mailing list. diff --git a/src/mailman/commands/docs/membership.rst b/src/mailman/commands/docs/membership.rst index 49e80511d..230b4fb83 100644 --- a/src/mailman/commands/docs/membership.rst +++ b/src/mailman/commands/docs/membership.rst @@ -217,9 +217,12 @@ list. ``unsubscribe`` is an alias for ``leave``. You may be asked to confirm your request. Anne is a member of the ``baker@example.com`` mailing list, when she decides -to leave it. She sends a message to the ``-leave`` address for the list and -is sent a confirmation message for her request. +to leave it. Because the mailing list allows for *open* unsubscriptions +(i.e. no confirmation is needed), when she sends a message to the ``-leave`` +address for the list, she is immediately removed. + >>> from mailman.interfaces.mailinglist import SubscriptionPolicy + >>> mlist_2.unsubscription_policy = SubscriptionPolicy.open >>> results = Results() >>> print(leave.process(mlist_2, msg, {}, (), results)) ContinueProcessing.yes diff --git a/src/mailman/commands/eml_membership.py b/src/mailman/commands/eml_membership.py index 4e2e78f5d..223552ea5 100644 --- a/src/mailman/commands/eml_membership.py +++ b/src/mailman/commands/eml_membership.py @@ -187,12 +187,14 @@ You may be asked to confirm your request.""") '$self.name: $email is not a member of $mlist.fqdn_listname'), file=results) return ContinueProcessing.no - getAdapter(mlist, ISubscriptionManager, name='unsubscribe').register( - user_address) - # member.unsubscribe() + manager = getAdapter(mlist, ISubscriptionManager, name='unsubscribe') + token, token_owner, member = manager.unregister(user_address) person = formataddr((user.display_name, email)) # noqa - print(_('Confirmation email sent to $person to leave' - ' $mlist.fqdn_listname'), file=results) + if member is None: + print(_('$person left $mlist.fqdn_listname'), file=results) + else: + print(_('Confirmation email sent to $person to leave' + ' $mlist.fqdn_listname'), file=results) return ContinueProcessing.yes diff --git a/src/mailman/interfaces/mailinglist.py b/src/mailman/interfaces/mailinglist.py index 2a862cde2..877016f41 100644 --- a/src/mailman/interfaces/mailinglist.py +++ b/src/mailman/interfaces/mailinglist.py @@ -257,6 +257,9 @@ class IMailingList(Interface): subscription_policy = Attribute( """The policy for subscribing new members to the list.""") + unsubscription_policy = Attribute( + """The policy for unsubscribing members from the list.""") + subscribers = Attribute( """An iterator over all IMembers subscribed to this list, with any role. diff --git a/src/mailman/runners/tests/test_leave.py b/src/mailman/runners/tests/test_leave.py index 64a46a4da..f54ab1ce8 100644 --- a/src/mailman/runners/tests/test_leave.py +++ b/src/mailman/runners/tests/test_leave.py @@ -24,6 +24,7 @@ from mailman.app.lifecycle import create_list from mailman.config import config from mailman.database.transaction import transaction from mailman.interfaces.usermanager import IUserManager +from mailman.interfaces.mailinglist import SubscriptionPolicy from mailman.runners.command import CommandRunner from mailman.testing.helpers import ( get_queue_messages, make_testable_runner, @@ -41,6 +42,7 @@ class TestLeave(unittest.TestCase): def setUp(self): self._mlist = create_list('test@example.com') self._mlist.send_welcome_message = False + self._mlist.unsubscription_policy = SubscriptionPolicy.open self._commandq = config.switchboards['command'] self._runner = make_testable_runner(CommandRunner, 'command') |
