|
|
@ -161,7 +161,8 @@ class Osichat(WebsocketConsumer):
|
|
|
|
}
|
|
|
|
}
|
|
|
|
if self.client_type == 'mobile_admin':
|
|
|
|
if self.client_type == 'mobile_admin':
|
|
|
|
chat_room_data = model_to_dict(chat_room)
|
|
|
|
chat_room_data = model_to_dict(chat_room)
|
|
|
|
chat_room_data['visitor'] = model_to_dict(chat_room.chatroomguest.visitor)
|
|
|
|
if hasattr(chat_room, 'chatroomguest') and chat_room.chatroomguest.visitor:
|
|
|
|
|
|
|
|
chat_room_data['visitor'] = model_to_dict(chat_room.chatroomguest.visitor)
|
|
|
|
if last_message:
|
|
|
|
if last_message:
|
|
|
|
chat_room_data['last_message'] = model_to_dict(last_message)
|
|
|
|
chat_room_data['last_message'] = model_to_dict(last_message)
|
|
|
|
else:
|
|
|
|
else:
|
|
|
@ -352,7 +353,7 @@ class OsitcomChatRoom(WebsocketConsumer):
|
|
|
|
)
|
|
|
|
)
|
|
|
|
|
|
|
|
|
|
|
|
if self.chat_room:
|
|
|
|
if self.chat_room:
|
|
|
|
self.group = f"{self.session_id}_{self.chat_room.id}"
|
|
|
|
self.group = f"chat_{self.chat_room.id}"
|
|
|
|
else:
|
|
|
|
else:
|
|
|
|
self.group = self.session_id #Visitor hasn't started a chat yet, when he will we will remove him from this group and add it to the chat group
|
|
|
|
self.group = self.session_id #Visitor hasn't started a chat yet, when he will we will remove him from this group and add it to the chat group
|
|
|
|
|
|
|
|
|
|
|
@ -580,15 +581,13 @@ class OsitcomChatRoom(WebsocketConsumer):
|
|
|
|
|
|
|
|
|
|
|
|
if self.client_type == 'mobile_admin':
|
|
|
|
if self.client_type == 'mobile_admin':
|
|
|
|
chat_room_data = model_to_dict(chat_room)
|
|
|
|
chat_room_data = model_to_dict(chat_room)
|
|
|
|
if hasattr(chat_room, 'chatroomguest'):
|
|
|
|
if hasattr(chat_room, 'chatroomguest') and chat_room.chatroomguest.visitor:
|
|
|
|
chat_room_data['visitor'] = {
|
|
|
|
chat_room_data['visitor'] = {
|
|
|
|
'id': chat_room.chatroomguest.visitor.id,
|
|
|
|
'id': chat_room.chatroomguest.visitor.id,
|
|
|
|
'country_flag': chat_room.chatroomguest.visitor.flag_image_url,
|
|
|
|
'country_flag': chat_room.chatroomguest.visitor.flag_image_url,
|
|
|
|
'is_online': chat_room.chatroomguest.visitor.is_online,
|
|
|
|
'is_online': chat_room.chatroomguest.visitor.is_online,
|
|
|
|
'ip': chat_room.chatroomguest.visitor.ip_address,
|
|
|
|
'ip': chat_room.chatroomguest.visitor.ip_address,
|
|
|
|
}
|
|
|
|
}
|
|
|
|
else:
|
|
|
|
|
|
|
|
chat_room_data['visitor'] = None
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
chat_members = ChatMember.objects.filter(room=chat_room)
|
|
|
|
chat_members = ChatMember.objects.filter(room=chat_room)
|
|
|
|
if chat_members.exists():
|
|
|
|
if chat_members.exists():
|
|
|
@ -597,7 +596,7 @@ class OsitcomChatRoom(WebsocketConsumer):
|
|
|
|
'id': member.member.id,
|
|
|
|
'id': member.member.id,
|
|
|
|
'first_name': member.member.first_name,
|
|
|
|
'first_name': member.member.first_name,
|
|
|
|
'last_name': member.member.last_name,
|
|
|
|
'last_name': member.member.last_name,
|
|
|
|
'image': member.member.staffprofile.image,
|
|
|
|
'image': member.member.staffprofile.image.url,
|
|
|
|
}
|
|
|
|
}
|
|
|
|
for member in chat_members
|
|
|
|
for member in chat_members
|
|
|
|
]
|
|
|
|
]
|
|
|
|