Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[12.0] [FIX] mail_tracking: reduce spammy score #926

Merged
merged 1 commit into from
Jul 27, 2022
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
18 changes: 12 additions & 6 deletions mail_tracking/models/ir_mail_server.py
Original file line number Diff line number Diff line change
Expand Up @@ -12,9 +12,8 @@ class IrMailServer(models.Model):
def _tracking_headers_add(self, tracking_email_id, headers):
"""Allow other addons to add its own tracking SMTP headers"""
headers = headers or {}
headers['X-Odoo-Database'] = getattr(
threading.currentThread(), 'dbname', None),
headers['X-Odoo-Tracking-ID'] = tracking_email_id
headers["X-Odoo-Database"] = getattr(threading.currentThread(), "dbname", None)
headers["X-Odoo-MailTracking-ID"] = tracking_email_id
return headers

def _tracking_email_id_body_get(self, body):
Expand Down Expand Up @@ -42,9 +41,16 @@ def build_email(self, email_from, email_to, subject, body, email_cc=None,
return msg

def _tracking_email_get(self, message):
tracking_email_id = False
if message.get('X-Odoo-Tracking-ID', '').isdigit():
tracking_email_id = int(message['X-Odoo-Tracking-ID'])
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
return self.env['mail.tracking.email'].browse(tracking_email_id)

def _smtp_server_get(self, mail_server_id, smtp_server):
Expand Down