summaryrefslogtreecommitdiff
path: root/Mailman/MailCommandHandler.py
diff options
context:
space:
mode:
authorbwarsaw2001-04-02 05:48:53 +0000
committerbwarsaw2001-04-02 05:48:53 +0000
commit7b46e58984efd02d53fd74056bb90e9a7daab8ff (patch)
treecef34fb475c1a78a556746fcbd2fd5fd09a32db9 /Mailman/MailCommandHandler.py
parentc9ace6eab4aa9d20e58364aa01ed0f8662a65c09 (diff)
downloadmailman-7b46e58984efd02d53fd74056bb90e9a7daab8ff.tar.gz
mailman-7b46e58984efd02d53fd74056bb90e9a7daab8ff.tar.zst
mailman-7b46e58984efd02d53fd74056bb90e9a7daab8ff.zip
__init__(): "join" is now a synonym for "subscribe". "remove" and
"leave" are synonyms for "unsubscribe". ProcessUnsubscribeCmd(): It is now legal to omit both the password and email address when unsubscribing via the -request address. If the password is omitted, a removal confirmation message is generated. However if the password was given, it must match the user's password or the removal fails. If the password matches, the removal is performed immediately. Note that there's an ambiguity if exactly one argument is given: is it a password or an email address? Use FindUser() to decide giving preference to email address.
Diffstat (limited to 'Mailman/MailCommandHandler.py')
-rw-r--r--Mailman/MailCommandHandler.py70
1 files changed, 51 insertions, 19 deletions
diff --git a/Mailman/MailCommandHandler.py b/Mailman/MailCommandHandler.py
index 8db51b516..f81c89caf 100644
--- a/Mailman/MailCommandHandler.py
+++ b/Mailman/MailCommandHandler.py
@@ -111,8 +111,11 @@ class MailCommandHandler:
self.__respbuf = ''
self.__dispatch = {
'subscribe' : self.ProcessSubscribeCmd,
+ 'join' : self.ProcessSubscribeCmd,
'confirm' : self.ProcessConfirmCmd,
'unsubscribe' : self.ProcessUnsubscribeCmd,
+ 'remove' : self.ProcessUnsubscribeCmd,
+ 'leave' : self.ProcessUnsubscribeCmd,
'who' : self.ProcessWhoCmd,
'info' : self.ProcessInfoCmd,
'lists' : self.ProcessListsCmd,
@@ -541,23 +544,49 @@ background and instructions for subscribing to and using it, visit:
trunc=0)
def ProcessUnsubscribeCmd(self, args, cmd, mail):
- if not len(args):
- self.AddError(_("Usage: unsubscribe <password> [<email-address>]"))
- return
- if len(args) > 2:
- self.AddError(_("Usage: unsubscribe <password> [<email-address>]\n"
- "To unsubscribe from a particular list, "
- "send your request\n"
- "to the '-request' address for that list."))
- return
- if len(args) == 2:
+ password = None
+ if not args:
+ # No password and no address. We can sniff the address, and we
+ # will do a confirmation notice.
+ addr = mail.get_sender()
+ elif len(args) == 1:
+ # We only got one argument, so we're not sure if that's the user's
+ # address or password. If the argument is a subscribed user, then
+ # assume its the address and send a confirmation notice.
+ # Otherwise, assume it's a password. This could seem weird if
+ # they're using their address as their password, but even still,
+ # it's not too bad.
+ if self.FindUser(args[0]):
+ addr = args[0]
+ else:
+ addr = mail.get_sender()
+ password = args[0]
+ elif len(args) == 2:
+ password = args[0]
addr = args[1]
else:
- addr = mail.get_sender()
+ self.AddError(Utils.wrap(
+ _("""Usage: unsubscribe [password] [email-address]
+
+ To unsubscribe from a particular list, send your request to
+ the `-request' address for that list."""),
+ honor_leading_ws = 0),
+ trunc = 0)
+ return
try:
- self.ConfirmUserPassword(addr, args[0])
- self.DeleteMember(addr, "mailcmd")
- self.AddToResponse(_("Succeeded."))
+ if password is None:
+ # Send a confirmation instead of unsubscribing them
+ if self.FindUser(addr):
+ self.ConfirmUnsubscription(addr)
+ self.AddToResponse(
+ _('A removal confirmation message has been sent.'))
+ else:
+ # Slightly bogus, but convenient
+ raise Errors.MMNoSuchUserError
+ else:
+ self.ConfirmUserPassword(addr, password)
+ self.DeleteMember(addr, "mailcmd")
+ self.AddToResponse(_("Succeeded."))
except Errors.MMListNotReadyError:
self.AddError(_("List is not functional."))
except (Errors.MMNoSuchUserError, Errors.MMNotAMemberError):
@@ -658,13 +687,16 @@ background and instructions for subscribing to and using it, visit:
return
try:
self.ProcessConfirmation(args[0])
- except Errors.MMBadConfirmation:
+ except Errors.MMBadConfirmation, e:
+ #syslog('debug', 'MMBadConfirmation: %s' % e)
# Express in approximate days
days = int(mm_cfg.PENDING_REQUEST_LIFE / mm_cfg.days(1) + 0.5)
- self.AddError(_('''Invalid confirmation string. Note that
- confirmation strings expire approximately %(days)s days after the
- initial subscription request. If your confirmation has expired,
- please try to re-submit your subscription.'''),
+ self.AddError(Utils.wrap(
+ _('''Invalid confirmation string. Note that confirmation
+ strings expire approximately %(days)s days after the initial
+ subscription request. If your confirmation has expired,
+ please try to re-submit your subscription.'''),
+ honor_leading_ws = 0),
trunc=0)
except Errors.MMNeedApproval, admin_addr:
self.AddToResponse(_('''Your request has been forwarded to the