In Frappe Chat Not Realtime Work in Backend Side


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.

as per my knowledge and after debug some code when user is logdin in system realtime is not working when ever you log out is work fine.

@pithiya_Nilesh check the socketio port

checked but no change @bahaou

def send(content: str, user: str, room: str, email: str):

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)
          event=room, message=result, user=chat_user

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

can you pls share the updated code and where to make changes @pithiya_Nilesh

# 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:
			return frappe.utils.unique(members)
		return []

Add this code in
this is temporary fix and its send notification to all chat operators, but it worked fine and also show realtime messages and notification.

@pithiya_Nilesh sorry but realtime messages are not being updated

hi, is there any update on this?

in send function()

new_message = frappe.get_doc(
            "doctype": "Chat Message",
            "content": content,
            "sender": user,
            "room": room,
            "sender_email": email,

add frappe.db.commit()

and still not work i share my repo for this.

is this working? @pithiya_Nilesh

i tried this and this is not working @pithiya_Nilesh