From 2d3a4a5d0cb2dbdd9a941d480b4989d7921c6100 Mon Sep 17 00:00:00 2001 From: Olivier Dony Date: Tue, 7 Mar 2017 19:53:01 +0100 Subject: [PATCH] [FIX] tools: generate message IDs with unique prefix For the purpose of fighting spam, many abuse/spam-fighting services provide redacted message IDs. Because we use a UNIX timestamp as the prefix for all message IDs, a redacted message ID of the form 1234XXXXX@domain.com is generally useless to find a `flagged` message's origin, because it matches most of the messages sent that day. Narrowing it down with the help of the approximate time of delivery does not help much, as there will still be dozens/hundreds of possible matches on a busy server. By swapping around the random token and the timestamp in the message ID, we should improve the uniqueness and "greppability" of our message IDs, once redacted. --- odoo/tools/mail.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/odoo/tools/mail.py b/odoo/tools/mail.py index cff0779a658..e1a4eeb9c54 100644 --- a/odoo/tools/mail.py +++ b/odoo/tools/mail.py @@ -436,7 +436,7 @@ def generate_tracking_message_id(res_id): except NotImplementedError: rnd = random.random() rndstr = ("%.15f" % rnd)[2:] - return "<%.15f.%s-openerp-%s@%s>" % (time.time(), rndstr, res_id, socket.gethostname()) + return "<%s.%.15f-openerp-%s@%s>" % (rndstr, time.time(), res_id, socket.gethostname()) def email_send(email_from, email_to, subject, body, email_cc=None, email_bcc=None, reply_to=False, attachments=None, message_id=None, references=None, openobject_id=False, debug=False, subtype='plain', headers=None,