fix(Communication): set In-Reply-To (#36746)

This commit is contained in:
s-aga-r 2026-02-09 10:42:19 +05:30 committed by GitHub
parent 5436194447
commit 786adfd341
No known key found for this signature in database
GPG key ID: B5690EEEBB952194
4 changed files with 9 additions and 1 deletions

View file

@ -52,6 +52,7 @@ def make(
now=False,
raw_html=False,
add_css=True,
in_reply_to=None,
**kwargs,
) -> dict[str, str]:
"""Make a new communication. Checks for email permissions for specified Document.
@ -73,6 +74,7 @@ def make(
:param send_after: Send after the given datetime.
:param raw_html: Whether to use html version of email template
:param add_css: Add default CSS from hooks/email_css to the email template (default **True**)
:param in_reply_to: Name of the Communication document to which this communication is a reply.
"""
from frappe.utils.commands import warn
@ -127,6 +129,7 @@ def make(
now=now,
raw_html=raw_html,
add_css=add_css,
in_reply_to=in_reply_to,
)
@ -157,6 +160,7 @@ def _make(
now=False,
raw_html=False,
add_css=True,
in_reply_to=None,
) -> dict[str, str]:
"""Internal method to make a new communication that ignores Permission checks."""
@ -185,6 +189,7 @@ def _make(
"has_attachment": 1 if attachments else 0,
"communication_type": communication_type,
"send_after": send_after,
"in_reply_to": in_reply_to,
}
)
comm.flags.skip_add_signature = not add_signature or (

View file

@ -311,6 +311,7 @@ class CommunicationEmailMixin:
"send_after": self.send_after,
"raw_html": raw_html,
"add_css": add_css,
"in_reply_to": self.in_reply_to,
}
def send_email(

View file

@ -755,7 +755,8 @@ class QueueBuilder:
mail.msg_root["Disposition-Notification-To"] = self.sender
if self.in_reply_to:
if message_id := frappe.db.get_value("Communication", self.in_reply_to, "message_id"):
mail.set_in_reply_to(get_string_between("<", message_id, ">"))
message_id = message_id.strip("<> \t\n")
mail.set_in_reply_to(f"<{message_id}>")
return mail
def process(self, send_now=False) -> EmailQueue | None:

View file

@ -870,6 +870,7 @@ frappe.views.CommunicationComposer = class {
print_language: form_values.print_language,
raw_html: form_values.use_html,
add_css: form_values.add_css,
in_reply_to: (this.is_a_reply && this.last_email?.name) || null,
},
btn,
callback(r) {