Merge branch 'alias' into 'master'
[mailman.git] / src / mailman / chains / discard.py
blob8faa748e3dc1b3464008b9233cbd5bc7db7a807c
1 # Copyright (C) 2007-2019 by the Free Software Foundation, Inc.
3 # This file is part of GNU Mailman.
5 # GNU Mailman is free software: you can redistribute it and/or modify it under
6 # the terms of the GNU General Public License as published by the Free
7 # Software Foundation, either version 3 of the License, or (at your option)
8 # any later version.
10 # GNU Mailman is distributed in the hope that it will be useful, but WITHOUT
11 # ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
12 # FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for
13 # more details.
15 # You should have received a copy of the GNU General Public License along with
16 # GNU Mailman. If not, see <http://www.gnu.org/licenses/>.
18 """The terminal 'discard' chain."""
20 import logging
22 from mailman.chains.base import TerminalChainBase
23 from mailman.core.i18n import _
24 from mailman.interfaces.chain import DiscardEvent
25 from public import public
26 from zope.event import notify
29 log = logging.getLogger('mailman.vette')
32 @public
33 class DiscardChain(TerminalChainBase):
34 """Discard a message."""
36 name = 'discard'
37 description = _('Discard a message and stop processing.')
39 def _process(self, mlist, msg, msgdata):
40 """See `TerminalChainBase`.
42 This writes a log message, fires a Zope event and then throws the
43 message away.
44 """
45 log.info('DISCARD: %s', msg.get('message-id', 'n/a'))
46 notify(DiscardEvent(mlist, msg, msgdata, self))
47 # Nothing more needs to happen.