summaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
authorBarry Warsaw2009-12-06 14:58:16 -0500
committerBarry Warsaw2009-12-06 14:58:16 -0500
commit49d5cdcd25627d639ca580a8d821414ef0be2c1f (patch)
treea5db4fdadd3aafa83ec6641a063e6c5389bb2558 /src
parentf7cbf566f32ac9819a6fc68652aee056cb7682a1 (diff)
downloadmailman-49d5cdcd25627d639ca580a8d821414ef0be2c1f.tar.gz
mailman-49d5cdcd25627d639ca580a8d821414ef0be2c1f.tar.zst
mailman-49d5cdcd25627d639ca580a8d821414ef0be2c1f.zip
Diffstat (limited to 'src')
-rw-r--r--src/mailman/commands/docs/membership.txt (renamed from src/mailman/commands/docs/join.txt)38
-rw-r--r--src/mailman/commands/eml_membership.py (renamed from src/mailman/commands/eml_join.py)23
2 files changed, 55 insertions, 6 deletions
diff --git a/src/mailman/commands/docs/join.txt b/src/mailman/commands/docs/membership.txt
index 67c84c24c..c381be4ee 100644
--- a/src/mailman/commands/docs/join.txt
+++ b/src/mailman/commands/docs/membership.txt
@@ -1,3 +1,4 @@
+==================
The 'join' command
==================
@@ -23,7 +24,7 @@ The mail command 'join' subscribes an email address to the mailing list.
No address to join
-------------------
+==================
>>> from mailman.email.message import Message
>>> from mailman.queue.command import Results
@@ -57,7 +58,7 @@ The 'subscribe' command is an alias.
Joining the sender
-------------------
+==================
When the message has a From field, that address will be subscribed.
@@ -140,7 +141,7 @@ Anne is also now a member of the mailing list.
Joining a second list
----------------------
+=====================
>>> mlist_2 = create_list('baker@example.com')
>>> msg = message_from_string("""\
@@ -170,3 +171,34 @@ One Anne confirms this subscription, she becomes a member of the mailing list.
>>> print mlist_2.members.get_member('anne@example.com')
<Member: Anne Person <anne@example.com>
on baker@example.com as MemberRole.member>
+
+
+Leaving a mailing list
+======================
+
+The mail command 'leave' unsubscribes an email address from the mailing list.
+'unsubscribe' is an alias for 'leave'.
+
+ >>> command = config.commands['leave']
+ >>> print command.name
+ leave
+ >>> print command.description
+ Leave this mailing list. You will be asked to confirm your request.
+
+Anne is a member of the baker@example.com mailing list, when she decides to
+leave it. She sends a message to the -leave address for the list and is sent
+a confirmation message for her request.
+
+ >>> results = Results()
+ >>> print command.process(mlist_2, msg, {}, (), results)
+ ContinueProcessing.yes
+ >>> print unicode(results)
+ The results of your email command are provided below.
+ <BLANKLINE>
+ Anne Person <anne@example.com> left baker@example.com
+ <BLANKLINE>
+
+Anne is no longer a member of the mailing list.
+
+ >>> print mlist_2.members.get_member('anne@example.com')
+ None
diff --git a/src/mailman/commands/eml_join.py b/src/mailman/commands/eml_membership.py
index 4e3f6edb9..7f61a4cb2 100644
--- a/src/mailman/commands/eml_join.py
+++ b/src/mailman/commands/eml_membership.py
@@ -29,6 +29,7 @@ __all__ = [
from email.utils import formataddr, parseaddr
+from zope.component import getUtility
from zope.interface import implements
from mailman.config import config
@@ -37,6 +38,7 @@ from mailman.interfaces.command import ContinueProcessing, IEmailCommand
from mailman.interfaces.domain import IDomainManager
from mailman.interfaces.member import DeliveryMode
from mailman.interfaces.registrar import IRegistrar
+from mailman.interfaces.usermanager import IUserManager
@@ -63,7 +65,8 @@ example:
"""See `IEmailCommand`."""
# Parse the arguments.
address, delivery_mode = self._parse_arguments(arguments)
- if address is None:
+ # address could be None or the empty string.
+ if not address:
real_name, address = parseaddr(msg['from'])
# Address could be None or the empty string.
if not address:
@@ -140,11 +143,25 @@ class Leave:
name = 'leave'
argument_description = ''
- description = ''
+ description = _(
+ 'Leave this mailing list. You will be asked to confirm your request.')
def process(self, mlist, msg, msgdata, arguments, results):
"""See `IEmailCommand`."""
- person = msg['from']
+ address = msg.sender
+ if not address:
+ print >> results, _(
+ '$self.name: No valid address found to unsubscribe')
+ return ContinueProcessing.no
+ member = mlist.members.get_member(address)
+ if member is None:
+ print >> results, _(
+ '$self.name: $address is not a member of $mlist.fqdn_listname')
+ return ContinueProcessing.no
+ member.unsubscribe()
+ # Get the user's full name.
+ user = getUtility(IUserManager).get_user(address)
+ person = formataddr((user.real_name, address))
print >> results, _('$person left $mlist.fqdn_listname')
return ContinueProcessing.yes