From 6df20f35c2d847d667b8408b652b3a97f0c26194 Mon Sep 17 00:00:00 2001 From: xoliqberdiyev Date: Tue, 21 Apr 2026 16:25:51 +0500 Subject: [PATCH] feat: uncomment significant code for ws --- core/apps/chat/consumers/chat.py | 35 +++++++++++++------------------- 1 file changed, 14 insertions(+), 21 deletions(-) diff --git a/core/apps/chat/consumers/chat.py b/core/apps/chat/consumers/chat.py index d4278e0..5806bc6 100644 --- a/core/apps/chat/consumers/chat.py +++ b/core/apps/chat/consumers/chat.py @@ -67,27 +67,20 @@ class ChatConsumer(AsyncWebsocketConsumer): await self._save_message(user, text) - # Uz - # Bu funksiya ishlatilmayapti, shuning uchun commentga olib qoydim, bu funksiya orniga /core/apps/chat/tasks/message.py ichida rest api yordamida message - # yuborilsa ishlatiladigan task bor. - - # En - # This function is not used, so I commented it out. Instead, a task is used in /core/apps/chat/tasks/message.py - # to send message when message is added from REST API. - - # async def chat_message(self, event): - # await self.send( - # text_data=json.dumps( - # { - # "id": event["id"], - # "message_type": event["message_type"], - # "text": event["text"], - # "file_url": event["file_url"], - # "sender": event["sender"], - # "created_at": event["created_at"], - # } - # ) - # ) + + async def chat_message(self, event): + await self.send( + text_data=json.dumps( + { + "id": event["id"], + "message_type": event["message_type"], + "text": event["text"], + "file_url": event["file_url"], + "sender": event["sender"], + "created_at": event["created_at"], + } + ) + ) @database_sync_to_async def _save_message(self, user, text):