From: Guillaume Pellerin Date: Wed, 29 Jun 2022 20:53:43 +0000 (+0200) Subject: notification: rm print, fix anonymous X-Git-Tag: 2.7.1~25 X-Git-Url: https://git.parisson.com/?a=commitdiff_plain;h=d4bbbda63bbe64a0ec2470f33d5f3af09cb9fdcc;p=teleforma.git notification: rm print, fix anonymous --- 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