diff --git a/src/snek/service/notification.py b/src/snek/service/notification.py index 27c65f4..6db762c 100644 --- a/src/snek/service/notification.py +++ b/src/snek/service/notification.py @@ -6,9 +6,12 @@ class NotificationService(BaseService): async def mark_as_read(self, user_uid, channel_message_uid): model = await self.get(user_uid, object_uid=channel_message_uid) + if not model: + return False model['read_at'] = now() await self.save(model) - + return True + async def get_unread_stats(self,user_uid): records = await self.query("SELECT object_type, COUNT(*) as count FROM notification WHERE user_uid=:user_uid AND read_at IS NULL GROUP BY object_type",dict(user_uid=user_uid))