1 # Copyright (C) 1998-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)
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
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 """Add the message to the list's current digest."""
22 from mailman
.app
.digests
import maybe_send_digest_now
23 from mailman
.core
.i18n
import _
24 from mailman
.interfaces
.handler
import IHandler
25 from mailman
.utilities
.mailbox
import Mailbox
26 from public
import public
27 from zope
.interface
import implementer
31 @implementer(IHandler
)
33 """Add the message to the digest, possibly sending it."""
36 description
= _('Add the message to the digest, possibly sending it.')
38 def process(self
, mlist
, msg
, msgdata
):
40 # Short-circuit if digests are not enabled or if this message already
42 if not mlist
.digests_enabled
or msgdata
.get('isdigest'):
44 # Open the mailbox that will be used to collect the current digest.
45 mailbox_path
= os
.path
.join(mlist
.data_path
, 'digest.mmdf')
46 # Lock the mailbox and append the message.
47 with
Mailbox(mailbox_path
, create
=True) as mbox
:
49 maybe_send_digest_now(mlist
)