]> git.parisson.com Git - teleforma.git/commitdiff
notification: rm print, fix anonymous
authorGuillaume Pellerin <guillaume.pellerin@ircam.fr>
Wed, 29 Jun 2022 20:53:43 +0000 (22:53 +0200)
committerGuillaume Pellerin <guillaume.pellerin@ircam.fr>
Wed, 29 Jun 2022 20:53:43 +0000 (22:53 +0200)
teleforma/ws/notification.py

index 5e64587a5e1b7aad9a8f0ccaaca4a0c8f04c4c7b..026c063dac7ccc0c51ecabdecbc5c40b937a90ed 100644 (file)
@@ -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