diff options
| author | Barry Warsaw | 2007-12-30 02:47:45 -0500 |
|---|---|---|
| committer | Barry Warsaw | 2007-12-30 02:47:45 -0500 |
| commit | 5b4bb22feca4d520afef44d1c472807e020d17b5 (patch) | |
| tree | 8d85431b8d129fad6c29dabd4d03c2eabe8a11d7 /Mailman/docs | |
| parent | 66ffab7c0d56b8144a80045fac3a7dab036a597f (diff) | |
| download | mailman-5b4bb22feca4d520afef44d1c472807e020d17b5.tar.gz mailman-5b4bb22feca4d520afef44d1c472807e020d17b5.tar.zst mailman-5b4bb22feca4d520afef44d1c472807e020d17b5.zip | |
Add three new rules and their associated doctests.
- A rule that checks to see if the sender is a moderated member.
- A rule that checks to see if the sender is a non-member.
- A rule that checks to see if the message has no (or an empty) Subject.
Give IMembers (and the associated database implementation) an `is_moderated`
flag.
Diffstat (limited to 'Mailman/docs')
| -rw-r--r-- | Mailman/docs/moderation.txt | 71 | ||||
| -rw-r--r-- | Mailman/docs/no-subject.txt | 35 |
2 files changed, 106 insertions, 0 deletions
diff --git a/Mailman/docs/moderation.txt b/Mailman/docs/moderation.txt new file mode 100644 index 000000000..0ce6bee6e --- /dev/null +++ b/Mailman/docs/moderation.txt @@ -0,0 +1,71 @@ +Member moderation +================= + +Each user has a moderation flag. When set, and the list is set to moderate +postings, then only members with a cleared moderation flag will be able to +email the list without having those messages be held for approval. The +'moderation' rule determines whether the message should be moderated or not. + + >>> from Mailman.configuration import config + >>> mlist = config.db.list_manager.create(u'_xtest@example.com') + >>> from Mailman.app.rules import find_rule + >>> rule = find_rule('moderation') + >>> rule.name + 'moderation' + +In the simplest case, the sender is not a member of the mailing list, so the +moderation rule can't match. + + >>> msg = message_from_string(u"""\ + ... From: aperson@example.org + ... To: _xtest@example.com + ... Subject: A posted message + ... + ... """) + >>> rule.check(mlist, msg, {}) + False + +Let's add the message author as a non-moderated member. + + >>> user = config.db.user_manager.create_user( + ... u'aperson@example.org', u'Anne Person') + >>> address = list(user.addresses)[0] + >>> from Mailman.interfaces import MemberRole + >>> member = address.subscribe(mlist, MemberRole.member) + >>> member.is_moderated + False + >>> rule.check(mlist, msg, {}) + False + +Once the member's moderation flag is set though, the rule matches. + + >>> member.is_moderated = True + >>> rule.check(mlist, msg, {}) + True + + +Non-members +----------- + +There is another, related rule for matching non-members, which simply matches +if the sender is /not/ a member of the mailing list. + + >>> rule = find_rule('non-member') + >>> rule.name + 'non-member' + +If the sender is a member of this mailing list, the rule does not match. + + >>> rule.check(mlist, msg, {}) + False + +But if the sender is not a member of this mailing list, the rule matches. + + >>> msg = message_from_string(u"""\ + ... From: bperson@example.org + ... To: _xtest@example.com + ... Subject: A posted message + ... + ... """) + >>> rule.check(mlist, msg, {}) + True diff --git a/Mailman/docs/no-subject.txt b/Mailman/docs/no-subject.txt new file mode 100644 index 000000000..3c6dc88bf --- /dev/null +++ b/Mailman/docs/no-subject.txt @@ -0,0 +1,35 @@ +No Subject header +================= + +This rule matches if the message has no Subject header, or if the header is +the empty string when stripped. + + >>> from Mailman.configuration import config + >>> mlist = config.db.list_manager.create(u'_xtest@example.com') + >>> from Mailman.app.rules import find_rule + >>> rule = find_rule('no-subject') + >>> rule.name + 'no-subject' + +A message with a non-empty subject does not match the rule. + + >>> msg = message_from_string(u"""\ + ... From: aperson@example.org + ... To: _xtest@example.com + ... Subject: A posted message + ... + ... """) + >>> rule.check(mlist, msg, {}) + False + +Delete the Subject header and the rule matches. + + >>> del msg['subject'] + >>> rule.check(mlist, msg, {}) + True + +Even a Subject header with only whitespace still matches the rule. + + >>> msg['Subject'] = u' ' + >>> rule.check(mlist, msg, {}) + True |
