aboutsummaryrefslogtreecommitdiffstats
path: root/Mailman/MailList.py
diff options
context:
space:
mode:
authorMark Sapiro <mark@msapiro.net>2020-01-09 17:00:40 -0800
committerMark Sapiro <mark@msapiro.net>2020-01-09 17:00:40 -0800
commit300671a6c0181f9792cb6bdc9d03f9016d3d1327 (patch)
treedf6af1a3727112ac3a1c37547df69c9120af8126 /Mailman/MailList.py
parentcf47ad68d9cdb269f3c1ea3d57f8b484141bfad5 (diff)
downloadmailman2-300671a6c0181f9792cb6bdc9d03f9016d3d1327.tar.gz
mailman2-300671a6c0181f9792cb6bdc9d03f9016d3d1327.tar.xz
mailman2-300671a6c0181f9792cb6bdc9d03f9016d3d1327.zip
Implement REFUSE_SECOND_PENDING setting to prevent multiple pending subscribes.
Diffstat (limited to '')
-rw-r--r--Mailman/MailList.py21
1 files changed, 21 insertions, 0 deletions
diff --git a/Mailman/MailList.py b/Mailman/MailList.py
index 12d75aff..9e6bbcb6 100644
--- a/Mailman/MailList.py
+++ b/Mailman/MailList.py
@@ -833,6 +833,25 @@ 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
+ this email.
+ """
+ if not mm_cfg.REFUSE_SECOND_PENDING:
+ return False
+ pends = self._Pending__load()
+ # Save and reload the db to evict expired pendings.
+ self._Pending__save(pends)
+ pends = self._Pending__load()
+ for k, v in pends.items():
+ if k in ('evictions', 'version'):
+ continue
+ op, data = v
+ if (op == Pending.SUBSCRIPTION and
+ data.address.lower() == email.lower()):
+ return True
+ return False
+
def InviteNewMember(self, userdesc, text=''):
"""Invite a new member to the list.
@@ -919,6 +938,8 @@ class MailList(HTMLFormatter, Deliverer, ListAdmin,
Utils.ValidateEmail(email)
if self.isMember(email):
raise Errors.MMAlreadyAMember, email
+ if self.CheckPending(email):
+ raise Errors.MMAlreadyPending, email
if email.lower() == self.GetListEmail().lower():
# Trying to subscribe the list to itself!
raise Errors.MMBadEmailError