I have installed frappe chat and implemented in my site, but in frappe chat realtime notification and chat is not working in backend side we need all time refresh desk to get notification and messages, on frontend side it worked fine. any idea about how to fix this. in github same issue are raised by multiple user but not any answer received yet.
problem in this line of code :-> for chat_user in frappe.get_cached_doc(“Chat Room”, room).get_members():
for chat_user in frappe.get_cached_doc("Chat Room", room).get_members():
frappe.publish_realtime(event=typing_event, user=chat_user, message=typing_data)
frappe.publish_realtime(
event=room, message=result, user=chat_user
)
frappe.publish_realtime(
event="latest_chat_updates",
message=result,
user=chat_user,
after_commit=True,
)
here only guest member is get in chat_user so only realtime work for Guest
you need to update this code and get backend member in chat_user variable to fix this issue
# Copyright (c) 2021, codescientist703 and contributors
# For license information, please see license.txt
import frappe
from frappe.model.document import Document
class ChatRoom(Document):
def get_members(self):
if self.members:
members = [x.strip() for x in self.members.split(",")]
for i in self.users:
members.append(i.user)
return frappe.utils.unique(members)
return []
Add this code in chat_room.py
this is temporary fix and its send notification to all chat operators, but it worked fine and also show realtime messages and notification.