fix: prevent unnecessary notification reloads for all users

- Emit WebSocket event only to the intended recipient instead of broadcasting
- Improves performance by reducing unnecessary API calls and WebSocket traffic
This commit is contained in:
Muhammed Raihan P A 2025-02-19 00:49:59 -08:00 committed by GitHub
parent 7101fadd36
commit a171f81738
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194

View File

@ -8,7 +8,8 @@ from frappe.model.document import Document
class CRMNotification(Document):
def on_update(self):
frappe.publish_realtime("crm_notification")
if self.to_user:
frappe.publish_realtime("crm_notification", user= self.to_user)
def notify_user(args):
"""
@ -33,4 +34,4 @@ def notify_user(args):
if frappe.db.exists("CRM Notification", values):
return
frappe.get_doc(values).insert(ignore_permissions=True)
frappe.get_doc(values).insert(ignore_permissions=True)