From d4bbbda63bbe64a0ec2470f33d5f3af09cb9fdcc Mon Sep 17 00:00:00 2001 From: Guillaume Pellerin Date: Wed, 29 Jun 2022 22:53:43 +0200 Subject: [PATCH] notification: rm print, fix anonymous --- teleforma/ws/notification.py | 9 +++++---- 1 file changed, 5 insertions(+), 4 deletions(-) diff --git a/teleforma/ws/notification.py b/teleforma/ws/notification.py index 5e64587a..026c063d 100644 --- a/teleforma/ws/notification.py +++ b/teleforma/ws/notification.py @@ -24,7 +24,6 @@ class NotificationConsumer(AsyncJsonWebsocketConsumer): # send initial messages data = await self.get_notifications_list(self.scope['user']) - print(data) await self.send_json(content={'type': 'initial', 'messages': data}) @@ -38,9 +37,11 @@ class NotificationConsumer(AsyncJsonWebsocketConsumer): @database_sync_to_async def get_notifications_list(self, user): # import pdb;pdb.set_trace() - messages = [message.to_dict() for message in Notification.objects.filter( - user=user).order_by('-created')][:20] - print(messages) + if user.is_authenticated: + messages = [message.to_dict() for message in Notification.objects.filter( + user=user).order_by('-created')][:20] + else: + messages = [] return messages # Receive message from channel -- 2.39.5