summaryrefslogtreecommitdiff
path: root/Mailman/pipeline/calculate_recipients.py
diff options
context:
space:
mode:
Diffstat (limited to 'Mailman/pipeline/calculate_recipients.py')
-rw-r--r--Mailman/pipeline/calculate_recipients.py104
1 files changed, 60 insertions, 44 deletions
diff --git a/Mailman/pipeline/calculate_recipients.py b/Mailman/pipeline/calculate_recipients.py
index 5cc552c25..f825e2d62 100644
--- a/Mailman/pipeline/calculate_recipients.py
+++ b/Mailman/pipeline/calculate_recipients.py
@@ -23,62 +23,78 @@ on the `recips' attribute of the message. This attribute is used by the
SendmailDeliver and BulkDeliver modules.
"""
+__metaclass__ = type
+__all__ = ['CalculateRecipients']
+
+from zope.interface import implements
+
from Mailman import Errors
from Mailman import Message
from Mailman import Utils
from Mailman.configuration import config
from Mailman.i18n import _
-from Mailman.interfaces import DeliveryStatus
+from Mailman.interfaces import DeliveryStatus, IHandler
-def process(mlist, msg, msgdata):
- # Short circuit if we've already calculated the recipients list,
- # regardless of whether the list is empty or not.
- if 'recips' in msgdata:
- return
- # Should the original sender should be included in the recipients list?
- include_sender = True
- sender = msg.get_sender()
- member = mlist.members.get_member(sender)
- if member and not member.receive_own_postings:
- include_sender = False
- # Support for urgent messages, which bypasses digests and disabled
- # delivery and forces an immediate delivery to all members Right Now. We
- # are specifically /not/ allowing the site admins password to work here
- # because we want to discourage the practice of sending the site admin
- # password through email in the clear. (see also Approve.py)
- missing = []
- password = msg.get('urgent', missing)
- if password is not missing:
- if mlist.Authenticate((config.AuthListModerator,
- config.AuthListAdmin),
- password):
- recips = mlist.getMemberCPAddresses(mlist.getRegularMemberKeys() +
- mlist.getDigestMemberKeys())
- msgdata['recips'] = recips
+class CalculateRecipients:
+ """Calculate the regular (i.e. non-digest) recipients of the message."""
+
+ implements(IHandler)
+
+ name = 'calculate-recipients'
+ description = _('Calculate the regular recipients of the message.')
+
+ def process(self, mlist, msg, msgdata):
+ # Short circuit if we've already calculated the recipients list,
+ # regardless of whether the list is empty or not.
+ if 'recips' in msgdata:
return
- else:
- # Bad Urgent: password, so reject it instead of passing it on. I
- # think it's better that the sender know they screwed up than to
- # deliver it normally.
- realname = mlist.real_name
- text = _("""\
+ # Should the original sender should be included in the recipients list?
+ include_sender = True
+ sender = msg.get_sender()
+ member = mlist.members.get_member(sender)
+ if member and not member.receive_own_postings:
+ include_sender = False
+ # Support for urgent messages, which bypasses digests and disabled
+ # delivery and forces an immediate delivery to all members Right Now.
+ # We are specifically /not/ allowing the site admins password to work
+ # here because we want to discourage the practice of sending the site
+ # admin password through email in the clear. (see also Approve.py)
+ #
+ # XXX This is broken.
+ missing = object()
+ password = msg.get('urgent', missing)
+ if password is not missing:
+ if mlist.Authenticate((config.AuthListModerator,
+ config.AuthListAdmin),
+ password):
+ recips = mlist.getMemberCPAddresses(
+ mlist.getRegularMemberKeys() +
+ mlist.getDigestMemberKeys())
+ msgdata['recips'] = recips
+ return
+ else:
+ # Bad Urgent: password, so reject it instead of passing it on.
+ # I think it's better that the sender know they screwed up
+ # than to deliver it normally.
+ realname = mlist.real_name
+ text = _("""\
Your urgent message to the %(realname)s mailing list was not authorized for
delivery. The original message as received by Mailman is attached.
""")
- raise Errors.RejectMessage, Utils.wrap(text)
- # Calculate the regular recipients of the message
- recips = set(member.address.address
- for member in mlist.regular_members.members
- if member.delivery_status == DeliveryStatus.enabled)
- # Remove the sender if they don't want to receive their own posts
- if not include_sender and member.address.address in recips:
- recips.remove(member.address.address)
- # Handle topic classifications
- do_topic_filters(mlist, msg, msgdata, recips)
- # Bookkeeping
- msgdata['recips'] = recips
+ raise Errors.RejectMessage, Utils.wrap(text)
+ # Calculate the regular recipients of the message
+ recips = set(member.address.address
+ for member in mlist.regular_members.members
+ if member.delivery_status == DeliveryStatus.enabled)
+ # Remove the sender if they don't want to receive their own posts
+ if not include_sender and member.address.address in recips:
+ recips.remove(member.address.address)
+ # Handle topic classifications
+ do_topic_filters(mlist, msg, msgdata, recips)
+ # Bookkeeping
+ msgdata['recips'] = recips