From 21949937636a2b0fc5b71a2667eede1750e05175 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Thibault=20Delavall=C3=A9e?= Date: Fri, 11 Dec 2015 18:14:58 +0100 Subject: [PATCH] [REM] mail: remove support of [ID] matching in subject in mail gateway This is an old compatibility code. It is time to remove it as it is not used sinces ages. --- addons/mail/models/mail_thread.py | 9 --------- addons/mail/tests/test_mail_gateway.py | 9 +-------- openerp/tools/mail.py | 3 --- 3 files changed, 1 insertion(+), 20 deletions(-) diff --git a/addons/mail/models/mail_thread.py b/addons/mail/models/mail_thread.py index d59ed690445..9a84e8546a4 100644 --- a/addons/mail/models/mail_thread.py +++ b/addons/mail/models/mail_thread.py @@ -1081,15 +1081,6 @@ class MailThread(models.AbstractModel): return routes # 5. Fallback to the provided parameters, if they work - if not thread_id: - # Legacy: fallback to matching [ID] in the Subject - match = tools.res_re.search(tools.decode_message_header(message, 'Subject')) - thread_id = match and match.group(1) - # Convert into int (bug spotted in 7.0 because of str) - try: - thread_id = int(thread_id) - except: - thread_id = False if fallback_model: route = self.message_route_verify( message, message_dict, diff --git a/addons/mail/tests/test_mail_gateway.py b/addons/mail/tests/test_mail_gateway.py index f5492dc22e9..5720dab2459 100644 --- a/addons/mail/tests/test_mail_gateway.py +++ b/addons/mail/tests/test_mail_gateway.py @@ -560,15 +560,8 @@ class TestMailgateway(TestMail): to='noone@example.com>', subject='spam', extra='In-Reply-To: <12321321-openerp-%d-mail.channel@neighbor.com>' % frog_groups.id) - # 4. Subject contains [] + model passed to message+process -> only attached to group, but not to mail (not in msg1.child_ids) - self.format_and_process( - MAIL_TEMPLATE, - to='erroneous@example.com', email_from='other6@gmail.com', - extra='', subject='Re: [%s] 1' % self.group_public.id, model='mail.channel', - msg_id='<1198923581.41972151344608186803.JavaMail.5@agrolait.com>') - # Test created messages - self.assertEqual(len(self.group_public.message_ids), 3, 'message_process: group should contain 6 messages') + self.assertEqual(len(self.group_public.message_ids), 2, 'message_process: group should contain 6 messages') self.assertEqual(len(self.group_public.message_ids[0].child_ids), 0, 'message_process: msg1 should not have children') @mute_logger('openerp.addons.mail.models.mail_thread', 'openerp.models') diff --git a/openerp/tools/mail.py b/openerp/tools/mail.py index 9646e4fde74..da4ec6fb716 100644 --- a/openerp/tools/mail.py +++ b/openerp/tools/mail.py @@ -403,9 +403,6 @@ email_re = re.compile(r"""([a-zA-Z0-9._%+-]+@[a-zA-Z0-9.-]+\.[a-zA-Z]{2,63})""", # matches a string containing only one email single_email_re = re.compile(r"""^[a-zA-Z0-9._%+-]+@[a-zA-Z0-9.-]+\.[a-zA-Z]{2,63}$""", re.VERBOSE) -# legacy behavior: match [ID] in the Subject, used with the fallback model of the mail gateway -res_re = re.compile(r"\[([0-9]+)\]", re.UNICODE) - # update command in emails body command_re = re.compile("^Set-([a-z]+) *: *(.+)$", re.I + re.UNICODE)