From b634063f564b9adb8b8e5377c48da2146f8fe72d Mon Sep 17 00:00:00 2001 From: Shariq Ansari Date: Tue, 11 Jun 2024 11:47:29 +0530 Subject: [PATCH] fix: append user email signature if content is empty --- crm/api/__init__.py | 37 ++++++++++++++++++- frontend/src/components/CommunicationArea.vue | 21 +++++++++-- 2 files changed, 54 insertions(+), 4 deletions(-) diff --git a/crm/api/__init__.py b/crm/api/__init__.py index 0039c426..533a30c0 100644 --- a/crm/api/__init__.py +++ b/crm/api/__init__.py @@ -1,5 +1,7 @@ +from bs4 import BeautifulSoup import frappe from frappe.translate import get_all_translations +from frappe.utils import cstr @frappe.whitelist(allow_guest=True) @@ -9,4 +11,37 @@ def get_translations(): else: language = frappe.db.get_single_value("System Settings", "language") - return get_all_translations(language) \ No newline at end of file + return get_all_translations(language) + + +@frappe.whitelist() +def get_user_signature(): + user = frappe.session.user + user_email_signature = ( + frappe.db.get_value( + "User", + user, + "email_signature", + ) + if user + else None + ) + + signature = user_email_signature or frappe.db.get_value( + "Email Account", + {"default_outgoing": 1, "add_signature": 1}, + "signature", + ) + + if not signature: + return + + soup = BeautifulSoup(signature, "html.parser") + html_signature = soup.find("div", {"class": "ql-editor read-mode"}) + _signature = None + if html_signature: + _signature = html_signature.renderContents() + content = "" + if (cstr(_signature) or signature): + content = f'

{signature}

' + return content \ No newline at end of file diff --git a/frontend/src/components/CommunicationArea.vue b/frontend/src/components/CommunicationArea.vue index b1a19b08..e090cf4b 100644 --- a/frontend/src/components/CommunicationArea.vue +++ b/frontend/src/components/CommunicationArea.vue @@ -1,5 +1,5 @@