summaryrefslogtreecommitdiff
path: root/addons/mass_mailing/models/mail_thread.py
diff options
context:
space:
mode:
authorThibault Delavallée <tde@openerp.com>2015-12-03 12:59:19 +0100
committerThibault Delavallée <tde@openerp.com>2016-09-01 10:41:04 +0200
commitb259eb69d2085a961c1ad00d8bba3cb8a92123c7 (patch)
treefbb7d975b55f290746589f2e6b43ff5cd03f07b0 /addons/mass_mailing/models/mail_thread.py
parentea4c4a22c41ec780818ec03ff6801791bda46065 (diff)
[CLEAN] mail, tools: factorize decode email tools
mail.mail and mail.thread have methods to decode headers. This commit move them in mail tools. It is indeed simplier to have all email tools in the same file. Moreover they have been renamed to avoid confusion with standard library methods: decode and decode_header already exist. * decode in mail_message is now decode_smtp_header * decode_header in mail_thread is now decode_message_header A method to data from references is also moved into tools. A regex was already defined in tools. Now the method using it is already put in tools. Mailgateway will now simply call this method.
Diffstat (limited to 'addons/mass_mailing/models/mail_thread.py')
-rw-r--r--addons/mass_mailing/models/mail_thread.py11
1 files changed, 4 insertions, 7 deletions
diff --git a/addons/mass_mailing/models/mail_thread.py b/addons/mass_mailing/models/mail_thread.py
index 1c0c8a38478..0931271509d 100644
--- a/addons/mass_mailing/models/mail_thread.py
+++ b/addons/mass_mailing/models/mail_thread.py
@@ -5,10 +5,7 @@ import logging
import re
from odoo import api, models
-
-from odoo.addons.mail.models.mail_message import decode
-from odoo.addons.mail.models.mail_thread import decode_header
-
+from odoo.tools import decode_smtp_header, decode_message_header
_logger = logging.getLogger(__name__)
@@ -24,8 +21,8 @@ class MailThread(models.AbstractModel):
return False to end the routing process. """
bounce_alias = self.env['ir.config_parameter'].get_param("mail.bounce.alias")
message_id = message.get('Message-Id')
- email_from = decode_header(message, 'From')
- email_to = decode_header(message, 'To')
+ email_from = decode_message_header(message, 'From')
+ email_to = decode_message_header(message, 'To')
# 0. Verify whether this is a bounced email (wrong destination,...) -> use it to collect data, such as dead leads
if bounce_alias and bounce_alias in email_to:
@@ -70,6 +67,6 @@ class MailThread(models.AbstractModel):
by using the References header of the incoming message and looking for
matching message_id in mail.mail.statistics. """
if message.get('References'):
- message_ids = [x.strip() for x in decode(message['References']).split()]
+ message_ids = [x.strip() for x in decode_smtp_header(message['References']).split()]
self.env['mail.mail.statistics'].set_replied(mail_message_ids=message_ids)
return super(MailThread, self).message_route_process(message, message_dict, routes)