diff options
author | Mark Sapiro <mark@msapiro.net> | 2020-05-18 10:01:51 -0700 |
---|---|---|
committer | Mark Sapiro <mark@msapiro.net> | 2020-05-18 10:01:51 -0700 |
commit | 248ca38ffb4821a131460c9953aa21d6fe7cec04 (patch) | |
tree | 0a9506f5eb6cf8ca369f3a18aa3e8be69c4d80f4 /Mailman/MailList.py | |
parent | 6432a3277d824ce149cf0d105bab6b78a91821a4 (diff) | |
download | mailman2-248ca38ffb4821a131460c9953aa21d6fe7cec04.tar.gz mailman2-248ca38ffb4821a131460c9953aa21d6fe7cec04.tar.xz mailman2-248ca38ffb4821a131460c9953aa21d6fe7cec04.zip |
Extend REFUSE_SECOND_PENDING to unsubscription as well.
Diffstat (limited to 'Mailman/MailList.py')
-rw-r--r-- | Mailman/MailList.py | 13 |
1 files changed, 9 insertions, 4 deletions
diff --git a/Mailman/MailList.py b/Mailman/MailList.py index 01a5a915..fdd47ae1 100644 --- a/Mailman/MailList.py +++ b/Mailman/MailList.py @@ -833,8 +833,8 @@ class MailList(HTMLFormatter, Deliverer, ListAdmin, # # Membership management front-ends and assertion checks # - def CheckPending(self, email): - """Check if there is already an unexpired pending subscription for + def CheckPending(self, email, unsub=False): + """Check if there is already an unexpired pending (un)subscription for this email. """ if not mm_cfg.REFUSE_SECOND_PENDING: @@ -846,8 +846,11 @@ class MailList(HTMLFormatter, Deliverer, ListAdmin, for k, v in pends.items(): if k in ('evictions', 'version'): continue - if (v[0] == Pending.SUBSCRIPTION and - v[1].address.lower() == email.lower()): + op, data = v[:2] + if (op == Pending.SUBSCRIPTION and not unsub and + data.address.lower() == email.lower() or + op == Pending.UNSUBSCRIPTION and unsub and + data.lower() == email.lower()): return True return False @@ -1476,6 +1479,8 @@ class MailList(HTMLFormatter, Deliverer, ListAdmin, assert 0, 'Bad op: %s' % op def ConfirmUnsubscription(self, addr, lang=None, remote=None): + if self.CheckPending(addr, unsub=True): + raise Errors.MMAlreadyPending, email if lang is None: lang = self.getMemberLanguage(addr) cookie = self.pend_new(Pending.UNSUBSCRIPTION, addr) |