From 6f71b6b5858ad9e0b8813370d8a63157f81dc5b3 Mon Sep 17 00:00:00 2001
From: Aungkokolin1997 <lin@quartile.co>
Date: Mon, 21 Aug 2023 08:29:40 +0630
Subject: [PATCH] [FIX] Allow messsage_content search only for internal users

---
 base_search_mail_content/models/mail_thread.py | 6 +++++-
 1 file changed, 5 insertions(+), 1 deletion(-)

diff --git a/base_search_mail_content/models/mail_thread.py b/base_search_mail_content/models/mail_thread.py
index 43a57df70..9c8f453d6 100644
--- a/base_search_mail_content/models/mail_thread.py
+++ b/base_search_mail_content/models/mail_thread.py
@@ -44,7 +44,11 @@ class MailThread(models.AbstractModel):
         that inherits mail.thread
         """
         res = super().get_view(view_id=view_id, view_type=view_type, options=options)
-        if view_type == "search" and self._fields.get("message_content"):
+        if (
+            view_type == "search"
+            and self._fields.get("message_content")
+            and self.env.user.has_group("base.group_user")
+        ):
             doc = etree.XML(res["arch"])
             for node in doc.xpath("/search/field[last()]"):
                 # Add message_content in search view