diff --git a/osinaweb/db.sqlite3 b/osinaweb/db.sqlite3 index 1c46c3b7..e30013d1 100644 Binary files a/osinaweb/db.sqlite3 and b/osinaweb/db.sqlite3 differ diff --git a/osinaweb/support/__pycache__/consumers.cpython-310.pyc b/osinaweb/support/__pycache__/consumers.cpython-310.pyc index db4ba3b5..7ed60baf 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 71ab0ec1..b87fe0fc 100644 --- a/osinaweb/support/consumers.py +++ b/osinaweb/support/consumers.py @@ -51,60 +51,6 @@ class TicketRoomConsumer(WebsocketConsumer): ) self.modify_online_user() - def receive(self, text_data): - text_data_json = json.loads(text_data) - event_type = text_data_json.get('event_type') - - if event_type == 'typing': - event = { - 'type': 'typing_handler', - 'user': self.scope['user'] - } - async_to_sync(self.channel_layer.group_send)( - self.ticket_number, event - ) - elif event_type == 'stop_typing': - event = { - 'type': 'stop_typing_handler', - } - async_to_sync(self.channel_layer.group_send)( - self.ticket_number, event - ) - elif event_type == 'update_reaction': - reaction = text_data_json['reaction'] - update_id = text_data_json['update_id'] - event = { - 'type': 'reaction_handler', - 'update_id': update_id, - 'reaction': reaction, - 'user': self.scope['user'] - } - async_to_sync(self.channel_layer.group_send)( - self.ticket_number, event - ) - else: - body = text_data_json['description'] - file_paths = text_data_json['filePath'] - ticketupdate = TicketUpdate.objects.create( - added_by=self.user, - description=body, - ticket=self.ticket, - date_added=datetime.now() - ) - for file_path in file_paths: - ticket_attachment = TicketAttachment( - ticket_update=ticketupdate, - file_path=file_path - ) - ticket_attachment.save() - event = { - 'type': 'update_handler', - 'update_id': ticketupdate.id - } - async_to_sync(self.channel_layer.group_send)( - self.ticket_number, event - ) - def update_handler(self, event): update_id = event['update_id'] update = TicketUpdate.objects.get(id=update_id) @@ -170,9 +116,11 @@ class TicketRoomConsumer(WebsocketConsumer): })) def modify_online_user(self): + connections = TicketConnection.objects.filter(ticket=self.ticket, terminated_at__isnull=True) event = { 'type': 'user_connection_handler', 'user': self.user, + 'connections': connections, } async_to_sync(self.channel_layer.group_send)( self.ticket_number, event @@ -180,6 +128,7 @@ class TicketRoomConsumer(WebsocketConsumer): def user_connection_handler(self, event): context = { + 'connections': event['connections'], 'user': event['user'] } html = render_to_string("details_templates/partials/ticket-online-users.html", context=context)