~barry/mailman/events-and-web

« back to all changes in this revision

Viewing changes to src/mailman/rules/docs/moderation.rst

  • Committer: klm
  • Date: 1998-01-07 21:21:35 UTC
  • Revision ID: vcs-imports@canonical.com-19980107212135-sv0y521ps0xye37r
Initial revision

Show diffs side-by-side

added added

removed removed

Lines of Context:
1
 
==========
2
 
Moderation
3
 
==========
4
 
 
5
 
All members and nonmembers have a moderation action.  When the action is not
6
 
`defer`, the `moderation` rule flags the message as needing moderation.  This
7
 
might be to automatically accept, discard, reject, or hold the message.
8
 
 
9
 
Two separate rules check for member and nonmember moderation.  Member
10
 
moderation happens early in the built-in chain, while nonmember moderation
11
 
happens later in the chain, after normal moderation checks.
12
 
 
13
 
    >>> mlist = create_list('test@example.com')
14
 
 
15
 
 
16
 
Member moderation
17
 
=================
18
 
 
19
 
    >>> member_rule = config.rules['member-moderation']
20
 
    >>> print member_rule.name
21
 
    member-moderation
22
 
 
23
 
Anne, a mailing list member, sends a message to the mailing list.  Her
24
 
postings are not moderated.
25
 
::
26
 
 
27
 
    >>> from mailman.testing.helpers import subscribe
28
 
    >>> subscribe(mlist, 'Anne')
29
 
    >>> member = mlist.members.get_member('aperson@example.com')
30
 
    >>> print member.moderation_action
31
 
    Action.defer
32
 
 
33
 
Because Anne is not moderated, the member moderation rule does not match.
34
 
 
35
 
    >>> member_msg = message_from_string("""\
36
 
    ... From: aperson@example.com
37
 
    ... To: test@example.com
38
 
    ... Subject: A posted message
39
 
    ...
40
 
    ... """)
41
 
    >>> member_rule.check(mlist, member_msg, {})
42
 
    False
43
 
 
44
 
Once the member's moderation action is set to something other than `defer`,
45
 
the rule matches.  Also, the message metadata has a few extra pieces of
46
 
information for the eventual moderation chain.
47
 
 
48
 
    >>> from mailman.interfaces.action import Action
49
 
    >>> member.moderation_action = Action.hold
50
 
    >>> msgdata = {}
51
 
    >>> member_rule.check(mlist, member_msg, msgdata)
52
 
    True
53
 
    >>> dump_msgdata(msgdata)
54
 
    moderation_action: hold
55
 
    moderation_sender: aperson@example.com
56
 
 
57
 
 
58
 
Nonmembers
59
 
==========
60
 
 
61
 
Nonmembers are handled in a similar way, although by default, nonmember
62
 
postings are held for moderator approval.
63
 
 
64
 
    >>> nonmember_rule = config.rules['nonmember-moderation']
65
 
    >>> print nonmember_rule.name
66
 
    nonmember-moderation
67
 
 
68
 
Bart, who is not a member of the mailing list, sends a message to the list.
69
 
 
70
 
    >>> from mailman.interfaces.member import MemberRole
71
 
    >>> subscribe(mlist, 'Bart', MemberRole.nonmember)
72
 
    >>> nonmember = mlist.nonmembers.get_member('bperson@example.com')
73
 
    >>> print nonmember.moderation_action
74
 
    Action.hold
75
 
 
76
 
When Bart is registered as a nonmember of the list, his moderation action is
77
 
set to hold by default.  Thus the rule matches and the message metadata again
78
 
carries some useful information.
79
 
 
80
 
    >>> nonmember_msg = message_from_string("""\
81
 
    ... From: bperson@example.com
82
 
    ... To: test@example.com
83
 
    ... Subject: A posted message
84
 
    ...
85
 
    ... """)
86
 
    >>> msgdata = {}
87
 
    >>> nonmember_rule.check(mlist, nonmember_msg, msgdata)
88
 
    True
89
 
    >>> dump_msgdata(msgdata)
90
 
    moderation_action: hold
91
 
    moderation_sender: bperson@example.com
92
 
 
93
 
Of course, the nonmember action can be set to defer the decision, in which
94
 
case the rule does not match.
95
 
 
96
 
    >>> nonmember.moderation_action = Action.defer
97
 
    >>> nonmember_rule.check(mlist, nonmember_msg, {})
98
 
    False
99
 
 
100
 
 
101
 
Unregistered nonmembers
102
 
=======================
103
 
 
104
 
The incoming runner ensures that all sender addresses are registered in the
105
 
system, but it is the moderation rule that subscribes nonmember addresses to
106
 
the mailing list if they are not already subscribed.
107
 
::
108
 
 
109
 
    >>> from mailman.interfaces.usermanager import IUserManager
110
 
    >>> from zope.component import getUtility
111
 
    >>> address = getUtility(IUserManager).create_address(
112
 
    ...     'cperson@example.com')
113
 
    >>> address
114
 
    <Address: cperson@example.com [not verified] at ...>
115
 
 
116
 
    >>> msg = message_from_string("""\
117
 
    ... From: cperson@example.com
118
 
    ... To: test@example.com
119
 
    ... Subject: A posted message
120
 
    ...
121
 
    ... """)
122
 
 
123
 
cperson is neither a member, nor a nonmember of the mailing list.
124
 
::
125
 
 
126
 
    >>> def memberkey(member):
127
 
    ...     return member.mailing_list, member.address.email, int(member.role)
128
 
 
129
 
    >>> dump_list(mlist.members.members, key=memberkey)
130
 
    <Member: Anne Person <aperson@example.com>
131
 
             on test@example.com as MemberRole.member>
132
 
    >>> dump_list(mlist.nonmembers.members, key=memberkey)
133
 
    <Member: Bart Person <bperson@example.com>
134
 
             on test@example.com as MemberRole.nonmember>
135
 
 
136
 
However, when the nonmember moderation rule runs, it adds the cperson as a
137
 
nonmember of the list.  The rule also matches.
138
 
 
139
 
    >>> msgdata = {}
140
 
    >>> nonmember_rule.check(mlist, msg, msgdata)
141
 
    True
142
 
    >>> dump_msgdata(msgdata)
143
 
    moderation_action: hold
144
 
    moderation_sender: cperson@example.com
145
 
 
146
 
    >>> dump_list(mlist.members.members, key=memberkey)
147
 
    <Member: Anne Person <aperson@example.com>
148
 
             on test@example.com as MemberRole.member>
149
 
    >>> dump_list(mlist.nonmembers.members, key=memberkey)
150
 
    <Member: Bart Person <bperson@example.com>
151
 
             on test@example.com as MemberRole.nonmember>
152
 
    <Member: cperson@example.com
153
 
             on test@example.com as MemberRole.nonmember>
154
 
 
155
 
 
156
 
Cross-membership checks
157
 
=======================
158
 
 
159
 
Of course, the member moderation rule does not match for nonmembers...
160
 
 
161
 
    >>> member_rule.check(mlist, nonmember_msg, {})
162
 
    False
163
 
    >>> nonmember_rule.check(mlist, member_msg, {})
164
 
    False