diff --git a/osinaweb/db.sqlite3 b/osinaweb/db.sqlite3 index 7afb0d59..c1ff7e21 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 36f754d5..0c8d8153 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 1d33f8ff..d4e47b3a 100644 --- a/osinaweb/osichat/consumers.py +++ b/osinaweb/osichat/consumers.py @@ -7,8 +7,7 @@ from django.shortcuts import get_object_or_404 import requests from django.forms.models import model_to_dict from django.core.serializers.json import DjangoJSONEncoder - - +from django.db.models import Case, When, F, Max, DateTimeField class OsitcomVisitor(WebsocketConsumer): def connect(self): async_to_sync(self.channel_layer.group_add)( @@ -72,10 +71,17 @@ class OsitcomChatRooms(WebsocketConsumer): def get_chats_handler(self): - chat_rooms = ChatRoom.objects.annotate(last_update=Max('chatmessage__date_sent')).order_by('-last_update', '-date_created') + + chat_rooms = ChatRoom.objects.annotate(last_update=Max('chatmessage__date_sent'), + order_key=Case( + 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 context = { 'chat_rooms': chat_rooms, } @@ -125,7 +131,7 @@ class OsitcomChatRooms(WebsocketConsumer): class OsitcomChatRoom(WebsocketConsumer): def connect(self): - self.domain = 'http://192.168.1.111:8000' + self.domain = 'http://192.168.1.109:8000' 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/osinacore/templates/details_templates/project-details.html b/osinaweb/osinacore/templates/details_templates/project-details.html index 92789a75..a7cdae8d 100644 --- a/osinaweb/osinacore/templates/details_templates/project-details.html +++ b/osinaweb/osinacore/templates/details_templates/project-details.html @@ -330,7 +330,7 @@ - + diff --git a/osinaweb/static/images/uploaded_chat_files/Artboard 4 (1).png b/osinaweb/static/images/uploaded_chat_files/Artboard 4 (1).png new file mode 100644 index 00000000..4a0f0ff4 Binary files /dev/null and b/osinaweb/static/images/uploaded_chat_files/Artboard 4 (1).png differ diff --git a/osinaweb/static/js/osichat-admin/rooms.js b/osinaweb/static/js/osichat-admin/rooms.js index 008cdf13..e92d0bdd 100644 --- a/osinaweb/static/js/osichat-admin/rooms.js +++ b/osinaweb/static/js/osichat-admin/rooms.js @@ -1,6 +1,6 @@ let admin_chat_ws_scheme = window.location.protocol === "https:" ? "wss" : "ws"; let protocol = window.location.protocol === "https:" ? "https" : "http"; -let admin_chat_domain = "192.168.1.111:8000"; +let admin_chat_domain = "192.168.1.109:8000"; let userId = document.getElementById('userId').textContent.trim(); let osichatroomsSocket; let osichatadminroomSocket; diff --git a/osinaweb/static/js/osichat/conversation.js b/osinaweb/static/js/osichat/conversation.js index 0b6b27a5..5d79e7b2 100644 --- a/osinaweb/static/js/osichat/conversation.js +++ b/osinaweb/static/js/osichat/conversation.js @@ -1,6 +1,6 @@ const chat_ws_scheme = window.location.protocol === "https:" ? "wss" : "ws"; const protocol = window.location.protocol === "https:" ? "https" : "http"; -const domain = "192.168.1.111:8000"; +const domain = "192.168.1.109:8000"; let osichatSocket; let isOpen = false; let chatLoaded = false; @@ -38,7 +38,7 @@ async function fetchSessionID() { let session_id = 'Unknown'; while (session_id === 'Unknown') { try { - const response = await fetch('http://192.168.1.111:3000/get-client-session/'); + const response = await fetch('http://192.168.1.109:3000/get-client-session/'); const data = await response.json(); if (data.session_id) { session_id = data.session_id; diff --git a/osinaweb/static/js/osichat/upload-file.js b/osinaweb/static/js/osichat/upload-file.js index b2285a81..07b6d8af 100644 --- a/osinaweb/static/js/osichat/upload-file.js +++ b/osinaweb/static/js/osichat/upload-file.js @@ -1,5 +1,5 @@ (function () { - const imageDomain = "http://192.168.1.111:8000"; + const imageDomain = "http://192.168.1.109:8000"; // TO TRIGGER TEH FILE UPLOADER WHEN CLICKING ON THE UPLOAD FILE SVG document.getElementById('svgFileUpload').addEventListener('click', function () { diff --git a/osinaweb/static/js/osichat/visitors.js b/osinaweb/static/js/osichat/visitors.js index 529f3d95..d42156df 100644 --- a/osinaweb/static/js/osichat/visitors.js +++ b/osinaweb/static/js/osichat/visitors.js @@ -1,11 +1,11 @@ const visitors_ws_scheme = window.location.protocol === "https:" ? "wss" : "ws"; -const my_domain = "192.168.1.111:8000"; +const my_domain = "192.168.1.109:8000"; async function fetchClientData() { let clientData = { client_ip: 'Unknown', client_country: 'Unknown' }; while (clientData.client_ip === 'Unknown') { try { - const response = await fetch('http://192.168.1.111:8000/get-client-ip/'); + const response = await fetch('http://192.168.1.109:8000/get-client-ip/'); const data = await response.json(); if (data.ip) { clientData = { @@ -25,7 +25,7 @@ async function fetchVisitorsSession() { let session_id = 'Unknown'; while (session_id === 'Unknown') { try { - const response = await fetch('http://192.168.1.111:3000/get-client-session/'); + const response = await fetch('http://192.168.1.109:3000/get-client-session/'); const data = await response.json(); if (data.session_id) { session_id = data.session_id;