diff options
| author | cotton | 1998-10-10 20:39:57 +0000 |
|---|---|---|
| committer | cotton | 1998-10-10 20:39:57 +0000 |
| commit | 734e659191d58fc6cdf0651bfc75635a292803c9 (patch) | |
| tree | 0fde5cef3720ac3ecd92b7006d35ce0837a06472 /Mailman/MailCommandHandler.py | |
| parent | 989b9c54b07ad980a3c739031e8cd3d8111ac1d2 (diff) | |
| download | mailman-734e659191d58fc6cdf0651bfc75635a292803c9.tar.gz mailman-734e659191d58fc6cdf0651bfc75635a292803c9.tar.zst mailman-734e659191d58fc6cdf0651bfc75635a292803c9.zip | |
These changing are a cleanup of the sorry state the subscription policy
was in (which was largely my fault from before).
Before:
1) web_subscribe_requires_confirmation was showing in the
admin cgi, but not working.
2) all subscribes that required admin approval were going
through the confirmation process.
3) the code implementing the confirmation process was
distributed between the subscribe cgi and
MailCommandHandler, duplicated in places and disrupting
the previous interface to list.AddMember.
4) the open_subscribe variable was confusing because
it didn't pay any attention to confirmations.
Now, things are organized a little differently, but in a much cleaner
way. there is one variable that deals with subscription policy, called
"subscribe_policy". It's setting determines what happens with both
the web based and the mail based subscriptions. there are 4 options:
0 - open subscribe policy
1 - confirmation required
2 - admin approval required
3 - confirmation and then admin approval required
there is a site configuration variable in Defaults.py called
ALLOW_OPEN_SUBSCRIBE, which determines whether or not an open
subscribe policy is an option. If it's not, the admin cgi interface
does not present it as an option.
I have restored a slightly modified version of the
prior-to-confirmations interface for list.AddMember, where all you
have to code is:
try:
list.AddMember(email, digest, password)
except Errors.MMBadEmail:
except Errors.MMAlreadySubscribed:
[ ... all those other good things it used to check ...]
except Errors.MMSubscribeNeedsConfirmation:
# the confirmation has already been sent.
# so just report accordingly to whatever the ap is.
In addition, I have moved the code for processing a confirmation
request to MailList.py so that it can be used in both a confirmation
cgi (which does not yet exist, but will) and the mailcmd script.
it's interface is:
try:
list.ProcessConfirmation(cookie)
except Errors.MMBadConfirmation:
# the cookie doesn't correspond to anything
except Errors.MMNeedApproval:
# the list is set to approve+confirm subscribe_policy.
A listing of the changes to the files follows:
Mailman/Defaults.in: added ALLOW_OPEN_SUBSCRIBE,DEFAULT_SUBSCRIBE_POLICY
deleted DEFAULT_OPEN_SUBSCRIBE, changed
DATA_FILE_VERSION to 5
Mailman/Errors.py: added MMBadConfirmation and
MMSubscribeNeedsConfirmation
Mailman/MailCommandHandler.py: moved the confirmation code to
MailList.py and use the new (old)
list.AddMember interface
MailMan/MailList.py: added .ProcessConfirmation(cookie), changed
AddMember to fit new (old) interface.
deleted config info for open_subscribe
and replaced with config info for
subscribe_policy that acts according to
mm_cfg.ALLOW_OPEN_SUBSCRIBE. Also made
list.ApprovedAddMember's "noack"
argument just "ack" for simplicities
sake and made it default to None
instead of 0 so that if the ack
variable isn't passed, it sets it to
the value of the lists
.send_welcome_msg setting.
Mailman/versions.py: added handling for new data file format,
replacing open_subscribe with a reasonable value
for subscribe_policy based on a combination of
what open_subscribe is and what
mm_cfg.ALLOW_OPEN_SUBSCRIBE is set to.
Mailman/Cgi/admin.py: made the cgi handle the output and processing of
subscribe_policy based on the setting of
mm_cfg.ALLOW_OPEN_SUBSCRIBE.
removed erroneous processing of whether or not
to send an ack with mass subscription based on
new interface to list.ApprovedAddMember (this
processing is to be replaced with a good idea
from john -- making mass subscribe have it's own
option of whether or not to send welcome
messages).
Mailman/Cgi/subscribe.py: made backgrounds white, and made it use the
MailList.AddMember interface described
above.
Mailman/Makefile.in: looks like this part of that distclean patch from
NAGY didn't make it in yet (rm'ing mm_cfg.py as well
as Defaults.py)
scott
Diffstat (limited to 'Mailman/MailCommandHandler.py')
| -rw-r--r-- | Mailman/MailCommandHandler.py | 134 |
1 files changed, 53 insertions, 81 deletions
diff --git a/Mailman/MailCommandHandler.py b/Mailman/MailCommandHandler.py index 4459b36d4..9ef4a5c42 100644 --- a/Mailman/MailCommandHandler.py +++ b/Mailman/MailCommandHandler.py @@ -445,45 +445,46 @@ class MailCommandHandler: password = "%s%s" % (Utils.GetRandomSeed(), Utils.GetRandomSeed()) if not address: - pending_addr = mail.GetSender() + subscribe_address = string.lower(mail.GetSender()) else: - pending_addr = address + subscribe_address = address remote = mail.GetSender() - if pending_addr == self.GetListEmail(): - badremote = "\n\tfrom " - if remote: badremote = badremote + remote - else: badremote = badremote + "unidentified sender" - self.LogMsg("mischief", ("Attempt to self subscribe %s:%s" - % (pending_addr, badremote))) - self.AddApprovalMsg("Attempt to subscribe a list to itself!") - return - if self.FindUser(pending_addr): - self.AddError("%s is already a list member." % pending_addr) - return - cookie = Pending.gencookie() - Pending.add2pending(pending_addr, password, digest, cookie) - if remote == pending_addr: - remote = "" + try: + self.AddMember(subscribe_address, password, digest, remote) + except Errors.MMSubscribeNeedsConfirmation: + # + # the confirmation message that's been sent takes place + # of the results of the mail command message + # + self.__NoMailCmdResponse = 1 + except Errors.MMNeedApproval, admin_email: + self.AddToResponse("your subscription request has been forwarded the list " + "administrator\nat %s for review.\n" % admin_email) + except Errors.MMBadEmailError: + self.AddError("Mailman won't accept the given email " + "address as a valid address. \n(Does it " + "have an @ in it???)") + except Errors.MMListNotReady: + self.AddError("The list is not fully functional, and " + "can not accept subscription requests.") + except Errors.MMHostileAddress: + self.AddError("Your subscription is not allowed because\n" + "the email address you gave is insecure.") + except Errors.MMAlreadyAMember: + self.AddError("You are already subscribed!") + except Errors.MMCantDigestError: + self.AddError("No one can subscribe to the digest of this list!") + except Errors.MMMustDigestError: + self.AddError("This list only supports digest subscriptions!") else: - remote = " from " + remote - text = Utils.maketext( - 'verify.txt', - {'email' : pending_addr, - 'listaddr' : self.GetListEmail(), - 'listname' : self.real_name, - 'listadmin' : self.GetAdminEmail(), - 'cookie' : cookie, - 'remote' : remote, - 'requestaddr' : self.GetRequestEmail(), - }) - self.SendTextToUser( - subject = "%s -- confirmation of subscription -- request %d" % - (self.real_name, cookie), - recipient = pending_addr, - sender = self.GetRequestEmail(), - text = text) - self.__NoMailCmdResponse = 1 - return + # + # if the list sends a welcome message, we don't need a response + # from the mailcommand handler. + # + if self.send_welcome_msg: + self.__NoMailCmdResponse = 1 + else: + self.AddToResponse("Succeeded") @@ -497,56 +498,27 @@ class MailCommandHandler: except: self.AddError("Usage: confirm <confirmation number>\n") return - pending = Pending.get_pending() - if not pending.has_key(cookie): + try: + self.ProcessConfirmation(cookie) + except Errors.MMBadConfirmation: self.AddError("Invalid confirmation number!\n" "Please recheck the confirmation number and" " try again.") - return - (email_addr, password, digest, ts) = pending[cookie] - if self.open_subscribe: - self.FinishSubscribe(email_addr, password, digest, - approved=1) + except Errors.MMNeedApproval, admin_addr: + self.AddToResponse("your request has been forwarded to the list " + "administrator for approval") + else: - self.FinishSubscribe(email_addr, password, digest) - del pending[cookie] - Pending.set_pending(pending) - - def FinishSubscribe(self, addr, password, digest, approved=0): - try: - if approved: - self.ApprovedAddMember(addr, password, digest) + # + # if the list sends a welcome message, we don't need a response + # from the mailcommand handler. + # + if self.send_welcome_msg: + self.__NoMailCmdResponse = 1 else: - self.AddMember(addr, password, digest) - self.AddToResponse("Succeeded.") - except Errors.MMBadEmailError: - self.AddError("Email address '%s' not accepted by Mailman." % - addr) - except Errors.MMMustDigestError: - self.AddError("List only accepts digest members.") - except Errors.MMCantDigestError: - self.AddError("List doesn't accept digest members.") - except Errors.MMListNotReady: - self.AddError("List is not functional.") - except Errors.MMNeedApproval: - self.AddApprovalMsg("Subscription is pending list admin approval.") - except Errors.MMHostileAddress: - self.AddError("Email address '%s' not accepted by Mailman " - "(insecure address)" % addr) - except Errors.MMAlreadyAMember: - self.AddError("%s is already a list member." % addr) - except: - self.AddError("An unknown Mailman error occured.") - self.AddError("Please forward your request to %s" % - self.GetAdminEmail()) - self.AddError("%s" % sys.exc_type) - self.LogMsg("error", ("%s:\n\t%s.FinishSubscribe() encountered" - " unexpected exception:\n\t'%s', '%s'" - % (__name__, - self._internal_name, - str(sys.exc_info()[0]), - str(sys.exc_info()[1])))) - + self.AddToResponse("Succeeded") + + def AddApprovalMsg(self, cmd): text = Utils.maketext( 'approve.txt', |
