From 7f960b7348234f3f3dd953e78d4805a1b5080f37 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Endika=20Guti=C3=A9rrez?= Date: Mon, 5 Feb 2024 16:43:49 +0100 Subject: [PATCH] Process Booking emails grouping key --- app/mailboxes/support_mailbox.rb | 8 +++++++- 1 file changed, 7 insertions(+), 1 deletion(-) diff --git a/app/mailboxes/support_mailbox.rb b/app/mailboxes/support_mailbox.rb index ca7f39a9ab181..94ee9bfdfb36c 100644 --- a/app/mailboxes/support_mailbox.rb +++ b/app/mailboxes/support_mailbox.rb @@ -52,8 +52,14 @@ def find_conversation_by_in_reply_to @account.conversations.where("additional_attributes->>'in_reply_to' = ?", in_reply_to).first end + BOOKING_CHAT_GROUPING = /(\d+)-.+@mchat.booking.com/ + def in_reply_to - mail['In-Reply-To'].try(:value) + in_reply_to = mail['In-Reply-To'].try(:value) + return in_reply_to if in_reply_to + + m = BOOKING_CHAT_GROUPING.match(mail.from) + "#{m[1]}@mchat.booking.com" if m end def find_or_create_conversation