diff --git a/osinaweb/db.sqlite3 b/osinaweb/db.sqlite3 index 87c8684b..35b3d157 100644 Binary files a/osinaweb/db.sqlite3 and b/osinaweb/db.sqlite3 differ diff --git a/osinaweb/osinacore/__pycache__/consumers.cpython-310.pyc b/osinaweb/osinacore/__pycache__/consumers.cpython-310.pyc index 289c548b..640143b9 100644 Binary files a/osinaweb/osinacore/__pycache__/consumers.cpython-310.pyc and b/osinaweb/osinacore/__pycache__/consumers.cpython-310.pyc differ diff --git a/osinaweb/static/js/tickets/tickets-room.js b/osinaweb/static/js/tickets/tickets-room.js index 4d442df8..9a4a0000 100644 --- a/osinaweb/static/js/tickets/tickets-room.js +++ b/osinaweb/static/js/tickets/tickets-room.js @@ -33,7 +33,8 @@ function app(socket) { sendTypingEvent: function () { if (this.socket && this.socket.readyState === WebSocket.OPEN) { clearTimeout(this.typingTimeout); - const data = { event_type: 'typing' }; + const userId = document.getElementById('userId').textContent.trim(); + const data = { event_type: 'typing', user_id: userId}; this.socket.send(JSON.stringify(data)); this.typingTimeout = setTimeout(() => { @@ -63,7 +64,8 @@ function app(socket) { function initializeWebSocket() { const ticketId = document.getElementById('ticketId').textContent.trim(); - const wsUrl = `wss://${window.location.host}/ws/ticketroom/${ticketId}/`; + const wsScheme = window.location.protocol === "https:" ? "wss" : "ws"; + const wsUrl = `${wsScheme}://${window.location.host}/ws/ticketroom/${ticketId}/`;; const socket = new WebSocket(wsUrl); socket.onopen = () => { diff --git a/osinaweb/support/__pycache__/consumers.cpython-310.pyc b/osinaweb/support/__pycache__/consumers.cpython-310.pyc index 1f0e2ca5..e95812e8 100644 Binary files a/osinaweb/support/__pycache__/consumers.cpython-310.pyc and b/osinaweb/support/__pycache__/consumers.cpython-310.pyc differ diff --git a/osinaweb/support/consumers.py b/osinaweb/support/consumers.py index bbda2923..a2e96585 100644 --- a/osinaweb/support/consumers.py +++ b/osinaweb/support/consumers.py @@ -58,6 +58,7 @@ class TicketRoomConsumer(WebsocketConsumer): if event_type == 'typing': event = { 'type': 'typing_handler', + 'user_id': text_data_json.get('user_id') } async_to_sync(self.channel_layer.group_send)( self.ticket_number, event @@ -119,8 +120,10 @@ class TicketRoomConsumer(WebsocketConsumer): })) def typing_handler(self, event): + user_id = event['user_id'] + typing_user = get_object_or_404(User, id=user_id) context = { - 'typing_user': self.scope['user'] + 'typing_user': typing_user } html = render_to_string("details_templates/partials/typing-message.html", context=context) self.send(text_data=json.dumps({ diff --git a/osinaweb/support/templates/details_templates/partials/typing-message.html b/osinaweb/support/templates/details_templates/partials/typing-message.html index d66ea623..73c2e35b 100644 --- a/osinaweb/support/templates/details_templates/partials/typing-message.html +++ b/osinaweb/support/templates/details_templates/partials/typing-message.html @@ -11,8 +11,8 @@ {{ typing_user.first_name.0 }}{{ typing_user.last_name.0 }} {% endif %} - {% elif user.staffprofile %} - {% if user.staffprofile.image %} + {% elif typing_user.staffprofile %} + {% if typing_user.staffprofile.image %} {% else %} diff --git a/osinaweb/support/templates/details_templates/ticket-room.html b/osinaweb/support/templates/details_templates/ticket-room.html index 987353df..3f74463b 100644 --- a/osinaweb/support/templates/details_templates/ticket-room.html +++ b/osinaweb/support/templates/details_templates/ticket-room.html @@ -15,7 +15,7 @@ - +