From 2ef1394e677c407fced6b731422b08f52b38db40 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Thibault=20Delavall=C3=A9e?= Date: Fri, 9 Feb 2018 10:12:19 +0100 Subject: [PATCH] [IMP] mass_mailing: use mail thread link replacer Mail thread now holds a method to replace local links by global links. Let us therefore use it in mass mailing as it does basically the same job. Adding base tag is not necessary anymore since there are not local links or images anymore. --- addons/mass_mailing/models/mail_mail.py | 10 +--------- 1 file changed, 1 insertion(+), 9 deletions(-) diff --git a/addons/mass_mailing/models/mail_mail.py b/addons/mass_mailing/models/mail_mail.py index e67010ca3a7..5889bbeede1 100644 --- a/addons/mass_mailing/models/mail_mail.py +++ b/addons/mass_mailing/models/mail_mail.py @@ -71,15 +71,7 @@ class MailMail(models.Model): new_href = href.replace(url, url + '/m/' + str(self.statistics_ids[0].id)) body = body.replace(href, new_href) - # prepend tag for images using absolute urls - domain = self.env["ir.config_parameter"].sudo().get_param("web.base.url") - base = "" % domain - body = tools.append_content_to_html(base, body, plaintext=False, container_tag='div') - # resolve relative image url to absolute for outlook.com - def _sub_relative2absolute(match): - return match.group(1) + werkzeug.urls.url_join(domain, match.group(2)) - body = re.sub('(]*\ssrc=")(/[^/][^"]+)', _sub_relative2absolute, body) - body = re.sub(r'(<[^>]+\bstyle="[^"]+\burl\(\'?)(/[^/\'][^\'")]+)', _sub_relative2absolute, body) + body = self.env['mail.thread']._replace_local_links(body) # generate tracking URL if self.statistics_ids: