diff --git a/osinaweb/osichat/__pycache__/consumers.cpython-310.pyc b/osinaweb/osichat/__pycache__/consumers.cpython-310.pyc index b593f325..22bffc97 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 dbe02a70..284538f1 100644 --- a/osinaweb/osichat/consumers.py +++ b/osinaweb/osichat/consumers.py @@ -189,10 +189,13 @@ class Osichat(WebsocketConsumer): def get_dms_handler(self, event): - 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(),)).filter(chatroomguest__isnull=True).order_by('-order_key') + if self.scope["user"].is_authenticated: + 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(),)).filter(chatroomguest__isnull=True, chatmember__member=self.scope["user"]).order_by('-order_key') + else: + chat_rooms = None context = { 'chat_rooms': chat_rooms, } @@ -214,7 +217,7 @@ class Osichat(WebsocketConsumer): 'id': member.member.id, 'first_name': member.member.first_name, 'last_name': member.member.last_name, - 'image': member.member.staffprofile.image.url if member.member.staffprofile and member.member.staffprofile.image else None + }) chat_room_data['members'] = member_data