diff options
author | Mark Sapiro <mark@msapiro.net> | 2013-09-27 16:33:35 -0700 |
---|---|---|
committer | Mark Sapiro <mark@msapiro.net> | 2013-09-27 16:33:35 -0700 |
commit | 5391cce1af71723b92bafc2419cec962f1e3ece3 (patch) | |
tree | e163c24a980fe14a202750c1a941c21700e0e346 /Mailman/Handlers/WrapMessage.py | |
parent | dbddbe175aeeacc668d1c78e1619528c7e828f6d (diff) | |
download | mailman2-5391cce1af71723b92bafc2419cec962f1e3ece3.tar.gz mailman2-5391cce1af71723b92bafc2419cec962f1e3ece3.tar.xz mailman2-5391cce1af71723b92bafc2419cec962f1e3ece3.zip |
Made author_is_list a 3-way with an option to wrap the message.
Diffstat (limited to 'Mailman/Handlers/WrapMessage.py')
-rw-r--r-- | Mailman/Handlers/WrapMessage.py | 57 |
1 files changed, 57 insertions, 0 deletions
diff --git a/Mailman/Handlers/WrapMessage.py b/Mailman/Handlers/WrapMessage.py new file mode 100644 index 00000000..350a8a81 --- /dev/null +++ b/Mailman/Handlers/WrapMessage.py @@ -0,0 +1,57 @@ +# Copyright (C) 2013 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. + +"""Wrap the message in an outer message/rfc822 part and transfer/add +some headers from the original. +""" + +import copy + +from Mailman import mm_cfg +from Mailman.Utils import unique_message_id +from Mailman.Message import Message + +# Headers from the original that we want to keep in the wrapper. +KEEPERS = ('to', + 'in-reply-to', + 'references', + 'x-mailman-approved-at', + ) + + + +def process(mlist, msg, msgdata): + if not mm_cfg.ALLOW_AUTHOR_IS_LIST or mlist.author_is_list != 2: + return + + # There are various headers in msg that we don't want, so we basically + # make a copy of the msg, then delete almost everything and set/copy + # what we want. + omsg = copy.deepcopy(msg) + for key in msg.keys(): + if key.lower() not in KEEPERS: + del msg[key] + msg['MIME-Version'] = '1.0' + msg['Content-Type'] = 'message/rfc822' + msg['Content-Disposition'] = 'inline' + msg['Message-ID'] = unique_message_id(mlist) + # Add the headers from CookHeaders. + for k, v in msgdata['add_header'].items(): + msg[k] = v + # And set the payload. + msg.set_payload(omsg.as_string()) + |