From 569553ab883624c9c0dc2217d4e16b6841fb0f23 Mon Sep 17 00:00:00 2001 From: Barry Warsaw Date: Wed, 15 Apr 2015 16:24:15 -0400 Subject: The SubscriptionWorkflow and Registar classes now have both a token and a "token owner". The latter describes who owns the token --i.e. which phase of the workflow is being waited on. It can either be no one, the subscriber, or the moderator. Tokens and token owners are properly initialized and reset when the workflow is completed, so we always know which step of the process is being waited on. Also, remove ISubscriptionService.join() since this will now be handled by the IRegistrar adapter. --- src/mailman/interfaces/subscriptions.py | 52 ++++++++------------------------- 1 file changed, 12 insertions(+), 40 deletions(-) (limited to 'src/mailman/interfaces/subscriptions.py') diff --git a/src/mailman/interfaces/subscriptions.py b/src/mailman/interfaces/subscriptions.py index 677f591ef..e6ffd29ce 100644 --- a/src/mailman/interfaces/subscriptions.py +++ b/src/mailman/interfaces/subscriptions.py @@ -19,14 +19,16 @@ __all__ = [ 'ISubscriptionService', + 'MissingUserError', 'RequestRecord', + 'TokenOwner', ] from collections import namedtuple - +from enum import Enum from mailman.interfaces.errors import MailmanError -from mailman.interfaces.member import DeliveryMode, MemberRole +from mailman.interfaces.member import DeliveryMode from zope.interface import Interface @@ -55,6 +57,14 @@ def RequestRecord(email, display_name='', return _RequestRecord(email, display_name, delivery_mode, language) + +class TokenOwner(Enum): + """Who 'owns' the token returned from the registrar?""" + no_one = 0 + subscriber = 1 + moderator = 2 + + class ISubscriptionService(Interface): """General Subscription services.""" @@ -104,44 +114,6 @@ class ISubscriptionService(Interface): def __iter__(): """See `get_members()`.""" - def join(list_id, subscriber, display_name=None, - delivery_mode=DeliveryMode.regular, - role=MemberRole.member): - """Subscribe to a mailing list. - - A user for the address is created if it is not yet known to Mailman, - however newly registered addresses will not yet be validated. No - confirmation message will be sent to the address, and the approval of - the subscription request is still dependent on the policy of the - mailing list. - - :param list_id: The list id of the mailing list the user is - subscribing to. - :type list_id: string - :param subscriber: The email address or user id of the user getting - subscribed. - :type subscriber: string or int - :param display_name: The name of the user. This is only used if a new - user is created, and it defaults to the local part of the email - address if not given. - :type display_name: string - :param delivery_mode: The delivery mode for this subscription. This - can be one of the enum values of `DeliveryMode`. If not given, - regular delivery is assumed. - :type delivery_mode: string - :param role: The membership role for this subscription. - :type role: `MemberRole` - :return: The just created member. - :rtype: `IMember` - :raises AlreadySubscribedError: if the user is already subscribed to - the mailing list. - :raises InvalidEmailAddressError: if the email address is not valid. - :raises MembershipIsBannedError: if the membership is not allowed. - :raises MissingUserError: when a bogus user id is given. - :raises NoSuchListError: if the named mailing list does not exist. - :raises ValueError: when `delivery_mode` is invalid. - """ - def leave(list_id, email): """Unsubscribe from a mailing list. -- cgit v1.2.3-70-g09d2