diff --git a/crm/api/comment.py b/crm/api/comment.py index 8f2df3f2..db90cb54 100644 --- a/crm/api/comment.py +++ b/crm/api/comment.py @@ -1,4 +1,5 @@ import frappe +from frappe import _ from bs4 import BeautifulSoup def on_update(self, method): @@ -15,13 +16,30 @@ def notify_mentions(doc): return mentions = extract_mentions(content) for mention in mentions: + owner = frappe.get_cached_value("User", doc.owner, "full_name") + doctype = doc.reference_doctype + if doctype.startswith("CRM "): + doctype = doctype[4:].lower() + notification_text = f""" +
+ + { owner } + + { _('mentioned you in {0}').format(doctype) } + + { doc.reference_name } + +
+ """ values = frappe._dict( doctype="CRM Notification", from_user=doc.owner, to_user=mention.email, type="Mention", message=doc.content, - comment=doc.name, + notification_text=notification_text, + notification_type_doctype="Comment", + notification_type_doc=doc.name, reference_doctype=doc.reference_doctype, reference_name=doc.reference_name, ) diff --git a/crm/api/notifications.py b/crm/api/notifications.py index 3dde662c..f7684e36 100644 --- a/crm/api/notifications.py +++ b/crm/api/notifications.py @@ -28,6 +28,9 @@ def get_notifications(): "to_user": notification.to_user, "read": notification.read, "comment": notification.comment, + "notification_text": notification.notification_text, + "notification_type_doctype": notification.notification_type_doctype, + "notification_type_doc": notification.notification_type_doc, "reference_doctype": "deal" if notification.reference_doctype == "CRM Deal" else "lead", diff --git a/frontend/src/components/Notifications.vue b/frontend/src/components/Notifications.vue index 5679b8db..8e7394ee 100644 --- a/frontend/src/components/Notifications.vue +++ b/frontend/src/components/Notifications.vue @@ -58,11 +58,14 @@
-
+
+
{{ n.from_user.full_name }} - {{ __('mentioned you in {0}', [n.reference_doctype]) }} + + {{ __('mentioned you in {0}', [n.reference_doctype]) }} + {{ n.reference_name }} @@ -128,7 +131,7 @@ function getRoute(notification) { return { name: notification.route_name, params: params, - hash: '#' + notification.comment, + hash: '#' + notification.comment || notification.notification_type_doc, } }