summaryrefslogtreecommitdiff
path: root/src/mailman/rest/docs/moderation.rst
blob: 44a2183ec926db61508204c038d44eafcff6fea6 (plain) (blame)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
=======================
Held message moderation
=======================

Held messages can be moderated through the REST API.  A mailing list starts
out with no held messages.

    >>> ant = create_list('ant@example.com')
    >>> transaction.commit()
    >>> dump_json('http://localhost:9001/3.0/lists/ant@example.com/held')
    http_etag: "..."
    start: 0
    total_size: 0

When a message gets held for moderator approval, it shows up in this list.
::

    >>> msg = message_from_string("""\
    ... From: anne@example.com
    ... To: ant@example.com
    ... Subject: Something
    ... Message-ID: <alpha>
    ...
    ... Something else.
    ... """)

    >>> from mailman.app.moderator import hold_message
    >>> request_id = hold_message(ant, msg, {'extra': 7}, 'Because')
    >>> transaction.commit()

    >>> dump_json('http://localhost:9001/3.0/lists/ant@example.com/held')
    entry 0:
        data: {u'_mod_subject': u'Something',
               u'_mod_message_id': u'<alpha>',
               u'extra': 7,
               u'_mod_fqdn_listname': u'ant@example.com',
               u'_mod_hold_date': u'2005-08-01T07:49:23',
               u'_mod_reason': u'Because',
               u'_mod_sender': u'anne@example.com'}
        http_etag: "..."
        id: 1
        key: <alpha>
    http_etag: "..."
    start: 0
    total_size: 1

You can get an individual held message by providing the *request id* for that
message.  This will include the text of the message.

    >>> dump_json('http://localhost:9001/3.0/lists/ant@example.com/held/1')
    data: {u'_mod_subject': u'Something',
           u'_mod_message_id': u'<alpha>',
           u'extra': 7,
           u'_mod_fqdn_listname': u'ant@example.com',
           u'_mod_hold_date': u'2005-08-01T07:49:23',
           u'_mod_reason': u'Because',
           u'_mod_sender': u'anne@example.com'}
    http_etag: "..."
    id: 1
    key: <alpha>
    msg:
    From: anne@example.com
    To: ant@example.com
    Subject: Something
    Message-ID: <alpha>
    X-Message-ID-Hash: GCSMSG43GYWWVUMO6F7FBUSSPNXQCJ6M
    <BLANKLINE>
    Something else.
    <BLANKLINE>

Individual messages can be moderated through the API by POSTing back to the
held message's resource.   The POST data requires an action of one of the
following:

  * discard - throw the message away.
  * reject - bounces the message back to the original author.
  * defer - defer any action on the message (continue to hold it)
  * accept - accept the message for posting.

Let's see what happens when the above message is deferred.

    >>> dump_json('http://localhost:9001/3.0/lists/ant@example.com/held/1', {
    ...     'action': 'defer',
    ...     })
    content-length: 0
    date: ...
    server: ...
    status: 204

The message is still in the moderation queue.

    >>> dump_json('http://localhost:9001/3.0/lists/ant@example.com/held/1')
    data: {u'_mod_subject': u'Something',
           u'_mod_message_id': u'<alpha>',
           u'extra': 7,
           u'_mod_fqdn_listname': u'ant@example.com',
           u'_mod_hold_date': u'2005-08-01T07:49:23',
           u'_mod_reason': u'Because',
           u'_mod_sender': u'anne@example.com'}
    http_etag: "..."
    id: 1
    key: <alpha>
    msg: From: anne@example.com
    To: ant@example.com
    Subject: Something
    Message-ID: <alpha>
    X-Message-ID-Hash: GCSMSG43GYWWVUMO6F7FBUSSPNXQCJ6M
    <BLANKLINE>
    Something else.
    <BLANKLINE>

The held message can be discarded.

    >>> dump_json('http://localhost:9001/3.0/lists/ant@example.com/held/1', {
    ...     'action': 'discard',
    ...     })
    content-length: 0
    date: ...
    server: ...
    status: 204

After which, the message is gone from the moderation queue.

    >>> dump_json('http://localhost:9001/3.0/lists/ant@example.com/held/1')
    Traceback (most recent call last):
    ...
    HTTPError: HTTP Error 404: 404 Not Found

- Hold another message
- Show accept
- Show reject? - probably not as we're just into testing app.moderator