try restore

This commit is contained in:
2024-01-02 15:23:29 +01:00
47 changed files with 1132 additions and 79 deletions

View File

@ -7,15 +7,17 @@ import time
import json
class ChatConsumer(WebsocketConsumer):
def connect(self):
user = self.scope["user"]
if (user.is_anonymous or not user.is_authenticated):
return
channel_id : int = int(self.scope['url_route']['kwargs']['chat_id'])
self.room_group_name = f'chat{channel_id}'
if ChatMemberModel.objects.filter(member_id=user.pk, channel_id=int(channel_id)).count() != 1:
return
@ -53,7 +55,7 @@ class ChatConsumer(WebsocketConsumer):
channel_id : int = int(self.scope['url_route']['kwargs']['chat_id'])
if ChatMemberModel.objects.filter(member_id=user.pk, channel_id=channel_id).count() != 1:
if ChatMemberModel.objects.filter(member_id = user.pk, channel_id = channel_id).count() != 1:
return
if (self.channel_layer == None):
@ -84,7 +86,6 @@ class ChatConsumer(WebsocketConsumer):
time = message_time
).save()
def chat_message(self, event):
user = self.scope["user"]