------------------------------------------------------------ revno: 1851 fixes bug: https://launchpad.net/bugs/1878458 committer: Mark Sapiro <m...@msapiro.net> branch nick: 2.1 timestamp: Mon 2020-05-18 10:01:51 -0700 message: Extend REFUSE_SECOND_PENDING to unsubscription as well. modified: Mailman/Cgi/options.py Mailman/Commands/cmd_unsubscribe.py Mailman/Defaults.py.in Mailman/MailList.py NEWS
-- lp:mailman/2.1 https://code.launchpad.net/~mailman-coders/mailman/2.1 Your team Mailman Checkins is subscribed to branch lp:mailman/2.1. To unsubscribe from this branch go to https://code.launchpad.net/~mailman-coders/mailman/2.1/+edit-subscription
=== modified file 'Mailman/Cgi/options.py' --- Mailman/Cgi/options.py 2020-05-05 15:08:54 +0000 +++ Mailman/Cgi/options.py 2020-05-18 17:01:51 +0000 @@ -206,6 +206,7 @@ # Are we processing an unsubscription request from the login screen? msgc = _('If you are a list member, a confirmation email has been sent.') + msgb = _('You already have a subscription pending confirmation') msga = _("""If you are a list member, your unsubscription request has been forwarded to the list administrator for approval.""") if cgidata.has_key('login-unsub'): @@ -228,6 +229,8 @@ mlist.ConfirmUnsubscription(user, userlang, remote=ip) doc.addError(msgc, tag='') mlist.Save() + except Errors.MMAlreadyPending: + doc.addError(msgb) finally: mlist.Unlock() else: === modified file 'Mailman/Commands/cmd_unsubscribe.py' --- Mailman/Commands/cmd_unsubscribe.py 2018-06-17 23:47:34 +0000 +++ Mailman/Commands/cmd_unsubscribe.py 2020-05-18 17:01:51 +0000 @@ -73,9 +73,14 @@ # No password was given, so we need to do a mailback confirmation # instead of unsubscribing them here. cpaddr = mlist.getMemberCPAddress(address) - mlist.ConfirmUnsubscription(cpaddr) - # We don't also need to send a confirmation to this command - res.respond = 0 + try: + mlist.ConfirmUnsubscription(cpaddr) + except Errors.MMAlreadyPending: + res.results.append( + _('You already have a subscription pending confirmation')) + else: + # We don't also need to send a confirmation to this command + res.respond = 0 else: # No admin approval is necessary, so we can just delete them if the # passwords match. === modified file 'Mailman/Defaults.py.in' --- Mailman/Defaults.py.in 2020-01-10 01:00:40 +0000 +++ Mailman/Defaults.py.in 2020-05-18 17:01:51 +0000 @@ -1128,7 +1128,7 @@ # pending a subscription confirmation when one is already pending. The down # side to this is if a subscriber loses or doesn't receive the confirmation # request email, she has to wait PENDING_REQUEST_LIFE (default 3 days) before -# she can request another. +# she can request another. This setting also applies to repeated unsubscribes. REFUSE_SECOND_PENDING = No === modified file 'Mailman/MailList.py' --- Mailman/MailList.py 2020-05-13 18:10:04 +0000 +++ Mailman/MailList.py 2020-05-18 17:01:51 +0000 @@ -833,8 +833,8 @@ # # 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 @@ 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 @@ 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) === modified file 'NEWS' --- NEWS 2020-05-13 18:10:04 +0000 +++ NEWS 2020-05-18 17:01:51 +0000 @@ -10,7 +10,8 @@ Bug Fixes and other patches - The fix for LP: #1859104 can result in ValueError being thrown on - attempts to subscribe to a list. This is fixed. (LP: #1878458) + attempts to subscribe to a list. This is fixed and extended to apply + REFUSE_SECOND_PENDING to unsubscription as well. (LP: #1878458) 2.1.33 (07-May-2020)
_______________________________________________ Mailman-checkins mailing list -- mailman-checkins@python.org To unsubscribe send an email to mailman-checkins-le...@python.org https://mail.python.org/mailman3/lists/mailman-checkins.python.org/ Member address: arch...@jab.org