[FIX] mail_tracking: reduce spammy score

Fix https://github.com/OCA/social/issues/701, following idea from https://kb.mailwizz.com/articles/low-score-in-spamassassin-because-of-the-rand_mktg_header-rule/ to avoid matching the regexp explained in https://bz.apache.org/SpamAssassin/show_bug.cgi?id=7888#c5

@Tecnativa TT29674
This commit is contained in:
Jairo Llopis 2021-07-09 10:41:39 +01:00 committed by Jasmin Solanki
parent 365e8a3c71
commit 814329c55a
2 changed files with 12 additions and 5 deletions

View File

@ -7,7 +7,7 @@
{ {
"name": "Email tracking", "name": "Email tracking",
"summary": "Email tracking system for all mails sent", "summary": "Email tracking system for all mails sent",
"version": "14.0.1.0.0", "version": "14.0.1.0.1",
"category": "Social Network", "category": "Social Network",
"website": "https://github.com/OCA/social", "website": "https://github.com/OCA/social",
"author": ("Tecnativa, " "Odoo Community Association (OCA)"), "author": ("Tecnativa, " "Odoo Community Association (OCA)"),

View File

@ -14,7 +14,7 @@ class IrMailServer(models.Model):
"""Allow other addons to add its own tracking SMTP headers""" """Allow other addons to add its own tracking SMTP headers"""
headers = headers or {} headers = headers or {}
headers["X-Odoo-Database"] = getattr(threading.currentThread(), "dbname", None) headers["X-Odoo-Database"] = getattr(threading.currentThread(), "dbname", None)
headers["X-Odoo-Tracking-ID"] = tracking_email_id headers["X-Odoo-MailTracking-ID"] = tracking_email_id
return headers return headers
def _tracking_email_id_body_get(self, body): def _tracking_email_id_body_get(self, body):
@ -64,9 +64,16 @@ class IrMailServer(models.Model):
return msg return msg
def _tracking_email_get(self, message): def _tracking_email_get(self, message):
try:
tracking_email_id = int(
message.get(
"X-Odoo-MailTracking-ID",
# Deprecated tracking header, kept as fallback
message["X-Odoo-Tracking-ID"],
)
)
except (TypeError, ValueError, KeyError):
tracking_email_id = False tracking_email_id = False
if message.get("X-Odoo-Tracking-ID", "").isdigit():
tracking_email_id = int(message["X-Odoo-Tracking-ID"])
return self.env["mail.tracking.email"].browse(tracking_email_id) return self.env["mail.tracking.email"].browse(tracking_email_id)
def _smtp_server_get(self, mail_server_id, smtp_server): def _smtp_server_get(self, mail_server_id, smtp_server):