summaryrefslogtreecommitdiff
path: root/src/mailman/app/subscriptions.py
diff options
context:
space:
mode:
authorBarry Warsaw2017-04-22 20:42:32 +0000
committerBarry Warsaw2017-04-22 20:42:32 +0000
commit23be50d1555977438e295ab219109ee1d934d14a (patch)
treef741381913dfc63477ca92c1c57f68704c4def28 /src/mailman/app/subscriptions.py
parentc975738f775398c255f63f0a9853212d7f024262 (diff)
parent0c5c9defb63981aeb95fc5b5bc76544020378f8b (diff)
downloadmailman-23be50d1555977438e295ab219109ee1d934d14a.tar.gz
mailman-23be50d1555977438e295ab219109ee1d934d14a.tar.zst
mailman-23be50d1555977438e295ab219109ee1d934d14a.zip
Diffstat (limited to 'src/mailman/app/subscriptions.py')
-rw-r--r--src/mailman/app/subscriptions.py19
1 files changed, 18 insertions, 1 deletions
diff --git a/src/mailman/app/subscriptions.py b/src/mailman/app/subscriptions.py
index 07d8e17da..0d1e979f5 100644
--- a/src/mailman/app/subscriptions.py
+++ b/src/mailman/app/subscriptions.py
@@ -32,7 +32,9 @@ from mailman.interfaces.address import IAddress
from mailman.interfaces.bans import IBanManager
from mailman.interfaces.listmanager import ListDeletingEvent
from mailman.interfaces.mailinglist import SubscriptionPolicy
-from mailman.interfaces.member import MembershipIsBannedError, NotAMemberError
+from mailman.interfaces.member import (
+ AlreadySubscribedError, MemberRole, MembershipIsBannedError,
+ NotAMemberError)
from mailman.interfaces.pending import IPendable, IPendings
from mailman.interfaces.subscriptions import (
ISubscriptionManager, ISubscriptionService,
@@ -198,6 +200,21 @@ class SubscriptionWorkflow(_SubscriptionWorkflowCommon):
self.address = addresses[0]
assert self.user is not None and self.address is not None, (
'Insane sanity check results')
+ # Is this subscriber already a member?
+ if (self.which is WhichSubscriber.user and
+ self.user.preferred_address is not None):
+ subscriber = self.user
+ else:
+ subscriber = self.address
+ if self.mlist.is_subscribed(subscriber):
+ # 2017-04-22 BAW: This branch actually *does* get covered, as I've
+ # verified by a full coverage run, but diffcov for some reason
+ # claims that the test added in the branch that added this code
+ # does not cover the change. That seems like a bug in diffcov.
+ raise AlreadySubscribedError( # pragma: no cover
+ self.mlist.fqdn_listname,
+ self.address.email,
+ MemberRole.member)
# Is this email address banned?
if IBanManager(self.mlist).is_banned(self.address.email):
raise MembershipIsBannedError(self.mlist, self.address.email)