summaryrefslogtreecommitdiff
path: root/Mailman/Handlers/CalcRecips.py
diff options
context:
space:
mode:
authorBarry Warsaw2007-06-19 11:13:09 -0400
committerBarry Warsaw2007-06-19 11:13:09 -0400
commit0514aa46113f1f44dcf86f2d8ae6f86b71e88a3d (patch)
tree67fe896a40781ed0a64656c3f0fce0fd4278240f /Mailman/Handlers/CalcRecips.py
parentc7d4e4c593d3bb1356fc099581d6f3e3deb0c1d4 (diff)
downloadmailman-0514aa46113f1f44dcf86f2d8ae6f86b71e88a3d.tar.gz
mailman-0514aa46113f1f44dcf86f2d8ae6f86b71e88a3d.tar.zst
mailman-0514aa46113f1f44dcf86f2d8ae6f86b71e88a3d.zip
Convert the tests for the CalcRecips handler to doc tests. There are
some XXX's in the doc test because digest recipients aren't tested (though those may go in a different doctest), and neither are urgent messages. This latter is for the same reason that the Approved handler is not yet tested; which password do you use in that header? The CalcRecips tests would also seem the natural place to test the receive_list_copy preference, but that actually gets processed in the AvoidDuplicates handler, so it isn't tested here. Add delivery_status (of type enum DeliveryStatus) to preferences. I'm not entirely sure that's the right place for it, but it lets me finish converting the test for now. Expose the rest of the preferences through the IMember interface.
Diffstat (limited to 'Mailman/Handlers/CalcRecips.py')
-rw-r--r--Mailman/Handlers/CalcRecips.py30
1 files changed, 11 insertions, 19 deletions
diff --git a/Mailman/Handlers/CalcRecips.py b/Mailman/Handlers/CalcRecips.py
index 5db860a79..29135999c 100644
--- a/Mailman/Handlers/CalcRecips.py
+++ b/Mailman/Handlers/CalcRecips.py
@@ -26,8 +26,8 @@ SendmailDeliver and BulkDeliver modules.
from Mailman import Errors
from Mailman import Message
from Mailman import Utils
-from Mailman.MemberAdaptor import ENABLED
from Mailman.configuration import config
+from Mailman.constants import DeliveryStatus
from Mailman.i18n import _
@@ -35,16 +35,14 @@ from Mailman.i18n import _
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 msgdata.has_key('recips'):
+ if 'recips' in msgdata:
return
# Should the original sender should be included in the recipients list?
- include_sender = 1
+ include_sender = True
sender = msg.get_sender()
- try:
- if mlist.getMemberOption(sender, config.DontReceiveOwnPosts):
- include_sender = 0
- except Errors.NotAMemberError:
- pass
+ 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
@@ -71,18 +69,12 @@ delivery. The original message as received by Mailman is attached.
""")
raise Errors.RejectMessage, Utils.wrap(text)
# Calculate the regular recipients of the message
- recips = [mlist.getMemberCPAddress(m)
- for m in mlist.getRegularMemberKeys()
- if mlist.getDeliveryStatus(m) == ENABLED]
+ 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:
- try:
- recips.remove(mlist.getMemberCPAddress(sender))
- except (Errors.NotAMemberError, ValueError):
- # Sender does not want to get copies of their own messages (not
- # metoo), but delivery to their address is disabled (nomail). Or
- # the sender is not a member of the mailing list.
- pass
+ 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