diff options
| author | Olivier Dony <odo@openerp.com> | 2011-09-08 02:16:51 +0200 |
|---|---|---|
| committer | Olivier Dony <odo@openerp.com> | 2011-09-08 02:16:51 +0200 |
| commit | da59a314e69bdfd0daa31cc90d179687fb01e0a4 (patch) | |
| tree | 30b5eaaec301a3fba4a7b2c72d356ab0994247c0 /addons/mail/mail_thread.py | |
| parent | eca9d6decf96b7d6e97b67242942bc6f3cf57dde (diff) | |
[IMP] mail.thread: support stripping attachments
bzr revid: odo@openerp.com-20110908001651-ns4nw0ri18xp7twf
Diffstat (limited to 'addons/mail/mail_thread.py')
| -rw-r--r-- | addons/mail/mail_thread.py | 8 |
1 files changed, 7 insertions, 1 deletions
diff --git a/addons/mail/mail_thread.py b/addons/mail/mail_thread.py index b72ef3f1635..a22e44bf351 100644 --- a/addons/mail/mail_thread.py +++ b/addons/mail/mail_thread.py @@ -297,7 +297,8 @@ class mail_thread(osv.osv): def message_process(self, cr, uid, model, message, custom_values=None, - save_original=False, context=None): + save_original=False, strip_attachments=False, + context=None): """Process an incoming RFC2822 email message related to the given thread model, relying on ``mail.message.parse()`` for the parsing operation, and then calling ``message_new`` @@ -315,6 +316,8 @@ class mail_thread(osv.osv): if the thread record already exists. :param bool save_original: whether to keep a copy of the original email source attached to the message after it is imported. + :param bool strip_attachments: whether to strip all attachments + before processing the message, in order to save some space. """ # extract message bytes - we are forced to pass the message as binary because # we don't know its encoding until we parse its headers and hence can't @@ -338,6 +341,9 @@ class mail_thread(osv.osv): msg_txt = email.message_from_string(message) msg = mail_message.parse_message(msg_txt, save_original=save_original) + if strip_attachments and 'attachments' in msg: + del msg['attachments'] + # Create New Record into particular model def create_record(msg): if hasattr(model_pool, 'message_new'): |
