"""
confirm <confirmation-string>
Confirm an action. The confirmation-string is required and should be
supplied by a mailback confirmation notice.
"""
from Mailman import mm_cfg
from Mailman import Errors
from Mailman import Pending
from Mailman.i18n import _
STOP = 1
def gethelp(mlist):
return _(__doc__)
def process(res, args):
mlist = res.mlist
if len(args) <> 1:
res.results.append(_('Usage:'))
res.results.append(gethelp(mlist))
return STOP
cookie = args[0]
try:
results = mlist.ProcessConfirmation(cookie, res.msg)
except Errors.MMBadConfirmation, e:
days = int(mm_cfg.PENDING_REQUEST_LIFE / mm_cfg.days(1) + 0.5)
res.results.append(_("""\
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 original request or
message."""))
except Errors.MMNeedApproval:
res.results.append(_("""\
Your request has been forwarded to the list moderator for approval."""))
except Errors.MMAlreadyAMember:
res.results.append(_('You are already subscribed.'))
except Errors.NotAMemberError:
res.results.append(_("""\
You are not currently a member. Have you already unsubscribed or changed
your email address?"""))
except Errors.HostileSubscriptionError:
res.results.append(_("""\
You were not invited to this mailing list. The invitation has been discarded,
and both list administrators have been alerted."""))
else:
if ((results[0] == Pending.SUBSCRIPTION and mlist.send_welcome_msg)
or
(results[0] == Pending.UNSUBSCRIPTION and mlist.send_goodbye_msg)):
res.respond = 0
else:
res.results.append(_('Confirmation succeeded'))
match = 'confirm ' + cookie
unprocessed = []
for line in res.commands:
if line.lstrip() == match:
continue
unprocessed.append(line)
res.commands = unprocessed
return STOP