summaryrefslogtreecommitdiff
path: root/mailman/commands
diff options
context:
space:
mode:
authorBarry Warsaw2008-09-23 23:30:05 -0400
committerBarry Warsaw2008-09-23 23:30:05 -0400
commit546825b4ec7a1018bc2182646e8c0433271d1990 (patch)
tree9e7b374bd0dd673a3197fc122e60148b8e8e5d8c /mailman/commands
parent48d54f30593abd1f018379ce3ecb3452be7986c0 (diff)
downloadmailman-546825b4ec7a1018bc2182646e8c0433271d1990.tar.gz
mailman-546825b4ec7a1018bc2182646e8c0433271d1990.tar.zst
mailman-546825b4ec7a1018bc2182646e8c0433271d1990.zip
Collect the initialization of adapters into a separate method.
Flesh out the join method.
Diffstat (limited to 'mailman/commands')
-rw-r--r--mailman/commands/docs/join.txt61
-rw-r--r--mailman/commands/join.py22
2 files changed, 67 insertions, 16 deletions
diff --git a/mailman/commands/docs/join.txt b/mailman/commands/docs/join.txt
index d9163fbb6..4cc805e99 100644
--- a/mailman/commands/docs/join.txt
+++ b/mailman/commands/docs/join.txt
@@ -71,10 +71,63 @@ When the message has a From field, that address will be subscribed.
>>> print command.process(mlist, msg, {}, (), results)
ContinueProcessing.yes
>>> print unicode(results)
- XXX
+ The results of your email command are provided below.
+ <BLANKLINE>
+ Confirmation email sent to Anne Person <anne@example.com>
+ <BLANKLINE>
Anne is not yet a member because she must confirm her subscription request
-first. Mailman has sent her the confirmation message.
+first.
+
+ >>> print config.db.user_manager.get_user(u'anne@example.com')
+ None
+
+Mailman has sent her the confirmation message.
+
+ >>> from mailman.queue import Switchboard
+ >>> virginq = Switchboard(config.VIRGINQUEUE_DIR)
+ >>> qmsg, qdata = virginq.dequeue(virginq.files[0])
+ >>> print qmsg.as_string()
+ MIME-Version: 1.0
+ ...
+ Subject: confirm ...
+ From: confirm-...@example.com
+ To: anne@example.com
+ ...
+ <BLANKLINE>
+ Email Address Registration Confirmation
+ <BLANKLINE>
+ Hello, this is the GNU Mailman server at example.com.
+ <BLANKLINE>
+ We have received a registration request for the email address
+ <BLANKLINE>
+ anne@example.com
+ <BLANKLINE>
+ Before you can start using GNU Mailman at this site, you must first
+ confirm that this is your email address. You can do this by replying to
+ this message, keeping the Subject header intact. Or you can visit this
+ web page
+ <BLANKLINE>
+ http://www.example.com/confirm/...
+ <BLANKLINE>
+ If you do not wish to register this email address simply disregard this
+ message. If you think you are being maliciously subscribed to the list, or
+ have any other questions, you may contact
+ <BLANKLINE>
+ postmaster@example.com
+ <BLANKLINE>
+
+Once Anne confirms her registration, she will be made a member of the mailing
+list.
+
+ >>> token = str(qmsg['subject']).split()[1].strip()
+ >>> from mailman.interfaces.registrar import IRegistrar
+ >>> registrar = IRegistrar(config.domains['example.com'])
+ >>> registrar.confirm(token)
+ True
- >>> for message in smtpd.messages:
- ... print message.as_string()
+ >>> user = config.db.user_manager.get_user(u'anne@example.com')
+ >>> print user.real_name
+ Anne Person
+ >>> list(user.addresses)
+ [<Address: Anne Person <anne@example.com> [verified] at ...>]
diff --git a/mailman/commands/join.py b/mailman/commands/join.py
index bfc3435e7..45535470f 100644
--- a/mailman/commands/join.py
+++ b/mailman/commands/join.py
@@ -24,7 +24,7 @@ __all__ = [
from email.header import decode_header, make_header
-from email.utils import parseaddr
+from email.utils import formataddr, parseaddr
from zope.interface import implements
from mailman.Utils import MakeRandomPassword
@@ -32,6 +32,7 @@ from mailman.configuration import config
from mailman.i18n import _
from mailman.interfaces import (
ContinueProcessing, DeliveryMode, IEmailCommand)
+from mailman.interfaces.registrar import IRegistrar
@@ -56,9 +57,9 @@ example:
def process(self, mlist, msg, msgdata, arguments, results):
"""See `IEmailCommand`."""
# Parse the arguments.
- address, delivery_mmode = self._parse_arguments(arguments)
+ address, delivery_mode = self._parse_arguments(arguments)
if address is None:
- realname, address = parseaddr(msg['from'])
+ real_name, address = parseaddr(msg['from'])
# Address could be None or the empty string.
if not address:
address = msg.get_sender()
@@ -66,15 +67,11 @@ example:
print >> results, _(
'$self.name: No valid address found to subscribe')
return ContinueProcessing.no
- password = MakeRandomPassword()
- try:
- validate_subscription(mlist, address)
- confirm_subscription(mlist, address, realname, password,
- delivery_mode, mlist_preferred_language)
- except XXX:
- pass
- print >> results, self.name, address, \
- (_('digest delivery') if digest else _('regular delivery'))
+ domain = config.domains[mlist.host_name]
+ registrar = IRegistrar(domain)
+ registrar.register(address, real_name)
+ person = formataddr((real_name, address))
+ print >> results, _('Confirmation email sent to $person')
return ContinueProcessing.yes
def _parse_arguments(self, arguments):
@@ -122,6 +119,7 @@ example:
address = parts[1]
return address, delivery_mode
+
def ignore():
# Fill in empty defaults
if digest is None: