1
=======================
2
Held message moderation
3
=======================
5
Held messages can be moderated through the REST API. A mailing list starts
6
out with no held messages.
8
>>> ant = create_list('ant@example.com')
9
>>> transaction.commit()
10
>>> dump_json('http://localhost:9001/3.0/lists/ant@example.com/held')
15
When a message gets held for moderator approval, it shows up in this list.
18
>>> msg = message_from_string("""\
19
... From: anne@example.com
20
... To: ant@example.com
21
... Subject: Something
22
... Message-ID: <alpha>
27
>>> from mailman.app.moderator import hold_message
28
>>> request_id = hold_message(ant, msg, {'extra': 7}, 'Because')
29
>>> transaction.commit()
31
>>> dump_json('http://localhost:9001/3.0/lists/ant@example.com/held')
33
data: {u'_mod_subject': u'Something',
34
u'_mod_message_id': u'<alpha>',
36
u'_mod_fqdn_listname': u'ant@example.com',
37
u'_mod_hold_date': u'2005-08-01T07:49:23',
38
u'_mod_reason': u'Because',
39
u'_mod_sender': u'anne@example.com'}
47
You can get an individual held message by providing the *request id* for that
48
message. This will include the text of the message.
50
>>> dump_json('http://localhost:9001/3.0/lists/ant@example.com/held/1')
51
data: {u'_mod_subject': u'Something',
52
u'_mod_message_id': u'<alpha>',
54
u'_mod_fqdn_listname': u'ant@example.com',
55
u'_mod_hold_date': u'2005-08-01T07:49:23',
56
u'_mod_reason': u'Because',
57
u'_mod_sender': u'anne@example.com'}
62
From: anne@example.com
66
X-Message-ID-Hash: GCSMSG43GYWWVUMO6F7FBUSSPNXQCJ6M
71
Individual messages can be moderated through the API by POSTing back to the
72
held message's resource. The POST data requires an action of one of the
75
* discard - throw the message away.
76
* reject - bounces the message back to the original author.
77
* defer - defer any action on the message (continue to hold it)
78
* accept - accept the message for posting.
80
Let's see what happens when the above message is deferred.
82
>>> dump_json('http://localhost:9001/3.0/lists/ant@example.com/held/1', {
83
... 'action': 'defer',
90
The message is still in the moderation queue.
92
>>> dump_json('http://localhost:9001/3.0/lists/ant@example.com/held/1')
93
data: {u'_mod_subject': u'Something',
94
u'_mod_message_id': u'<alpha>',
96
u'_mod_fqdn_listname': u'ant@example.com',
97
u'_mod_hold_date': u'2005-08-01T07:49:23',
98
u'_mod_reason': u'Because',
99
u'_mod_sender': u'anne@example.com'}
103
msg: From: anne@example.com
107
X-Message-ID-Hash: GCSMSG43GYWWVUMO6F7FBUSSPNXQCJ6M
112
The held message can be discarded.
114
>>> dump_json('http://localhost:9001/3.0/lists/ant@example.com/held/1', {
115
... 'action': 'discard',
122
After which, the message is gone from the moderation queue.
124
>>> dump_json('http://localhost:9001/3.0/lists/ant@example.com/held/1')
125
Traceback (most recent call last):
127
HTTPError: HTTP Error 404: 404 Not Found
129
- Hold another message
131
- Show reject? - probably not as we're just into testing app.moderator