From 580ec5ab0d57a542ab38b25a6c508804d5bcfa21 Mon Sep 17 00:00:00 2001 From: retoor Date: Wed, 5 Mar 2025 17:52:18 +0100 Subject: [PATCH] Notifications accept. --- src/snek/service/notification.py | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) 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))