diff --git a/.DS_Store b/.DS_Store index c2a6a0cb..efe0d738 100644 Binary files a/.DS_Store and b/.DS_Store differ diff --git a/osinaweb/.DS_Store b/osinaweb/.DS_Store index 87b62318..cc96f7b3 100644 Binary files a/osinaweb/.DS_Store and b/osinaweb/.DS_Store differ diff --git a/osinaweb/db.sqlite3 b/osinaweb/db.sqlite3 index c1ff7e21..259b267e 100644 Binary files a/osinaweb/db.sqlite3 and b/osinaweb/db.sqlite3 differ diff --git a/osinaweb/osichat/__pycache__/consumers.cpython-310.pyc b/osinaweb/osichat/__pycache__/consumers.cpython-310.pyc index 0c8d8153..d9f9096c 100644 Binary files a/osinaweb/osichat/__pycache__/consumers.cpython-310.pyc and b/osinaweb/osichat/__pycache__/consumers.cpython-310.pyc differ diff --git a/osinaweb/osichat/consumers.py b/osinaweb/osichat/consumers.py index d4e47b3a..7766ff5c 100644 --- a/osinaweb/osichat/consumers.py +++ b/osinaweb/osichat/consumers.py @@ -77,8 +77,9 @@ class OsitcomChatRooms(WebsocketConsumer): When(last_update__isnull=True, then=F('date_created')), default=F('last_update'), output_field=DateTimeField(),)).order_by('-order_key') - + user = get_object_or_404(User, id=self.user_id) + for room in chat_rooms: room.number_of_unread = room.unread_messages(user) room.last_message = room.last_updated @@ -87,7 +88,23 @@ class OsitcomChatRooms(WebsocketConsumer): } if self.client_type == 'mobile_admin': - chat_rooms_data = [model_to_dict(chat_room) for chat_room in chat_rooms] + chat_rooms_data = [] + for chat_room in chat_rooms: + room_data = model_to_dict(chat_room) + room_data['number_of_unread'] = chat_room.unread_messages(user) + room_data['last_message'] = chat_room.last_updated + if hasattr(chat_room, 'chatroomguest') and chat_room.chatroomguest.visitor: + visitor = chat_room.chatroomguest.visitor + room_data['visitor'] = { + 'session_id': visitor.session_id, + 'ip': visitor.ip_address, + 'country': visitor.country, + 'country_flag': visitor.flag_image_url, + 'name': visitor.name, + 'mobile_number': visitor.mobile_number, + } + chat_rooms_data.append(room_data) + self.send(text_data=json.dumps({ 'event_type': 'get_chats', 'chat_rooms_data': chat_rooms_data, @@ -131,7 +148,7 @@ class OsitcomChatRooms(WebsocketConsumer): class OsitcomChatRoom(WebsocketConsumer): def connect(self): - self.domain = 'http://192.168.1.109:8000' + self.domain = 'https://osina.ositcom.com' self.session_id = self.scope['url_route']['kwargs']['session_id'] self.visitor = Visitor.objects.filter(session_id=self.session_id).last() diff --git a/osinaweb/osichat/templates/chat-room.html b/osinaweb/osichat/templates/chat-room.html index cbd4df33..8c064838 100644 --- a/osinaweb/osichat/templates/chat-room.html +++ b/osinaweb/osichat/templates/chat-room.html @@ -4,7 +4,7 @@
-