summaryrefslogtreecommitdiff
path: root/Mailman/chains/builtin.py
blob: e5e97c3fb47b4f79e3be07a4697fcc4c2a48ea43 (plain)
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
# Copyright (C) 2007-2008 by the Free Software Foundation, Inc.
#
# This program is free software; you can redistribute it and/or
# modify it under the terms of the GNU General Public License
# as published by the Free Software Foundation; either version 2
# of the License, or (at your option) any later version.
#
# This program is distributed in the hope that it will be useful,
# but WITHOUT ANY WARRANTY; without even the implied warranty of
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
# GNU General Public License for more details.
#
# You should have received a copy of the GNU General Public License
# along with this program; if not, write to the Free Software
# Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301,
# USA.

"""The default built-in starting chain."""

__all__ = ['BuiltInChain']
__metaclass__ = type


import logging

from Mailman.interfaces import LinkAction
from Mailman.chains.base import Chain, Link
from Mailman.i18n import _


log = logging.getLogger('mailman.vette')



class BuiltInChain(Chain):
    """Default built-in chain."""

    def __init__(self):
        super(BuiltInChain, self).__init__(
            'built-in', _('The built-in moderation chain.'))
        self.append_link(Link('approved', LinkAction.jump, 'accept'))
        self.append_link(Link('emergency', LinkAction.jump, 'hold'))
        self.append_link(Link('loop', LinkAction.jump, 'discard'))
        # Do all of the following before deciding whether to hold the message
        # for moderation.
        self.append_link(Link('administrivia', LinkAction.defer))
        self.append_link(Link('implicit-dest', LinkAction.defer))
        self.append_link(Link('max-recipients', LinkAction.defer))
        self.append_link(Link('max-size', LinkAction.defer))
        self.append_link(Link('news-moderation', LinkAction.defer))
        self.append_link(Link('no-subject', LinkAction.defer))
        self.append_link(Link('suspicious-header', LinkAction.defer))
        # Now if any of the above hit, jump to the hold chain.
        self.append_link(Link('any', LinkAction.jump, 'hold'))
        # Take a detour through the self header matching chain, which we'll
        # create later.
        self.append_link(Link('truth', LinkAction.detour, 'header-match'))
        # Finally, the builtin chain selfs to acceptance.
        self.append_link(Link('truth', LinkAction.jump, 'accept'))