From afbf53938bd59e1e03dfc011063b27134dd0c054 Mon Sep 17 00:00:00 2001
From: retoor <retoor@molodetz.nl>
Date: Wed, 5 Mar 2025 18:09:54 +0100
Subject: [PATCH] Notifications accept.

---
 src/snek/service/chat.py         | 6 ++----
 src/snek/service/notification.py | 5 +++++
 2 files changed, 7 insertions(+), 4 deletions(-)

diff --git a/src/snek/service/chat.py b/src/snek/service/chat.py
index 54e60dc..17c677b 100644
--- a/src/snek/service/chat.py
+++ b/src/snek/service/chat.py
@@ -17,10 +17,8 @@ class ChatService(BaseService):
             message
         )
         channel_message_uid = channel_message["uid"]
-        if not channel_message['new_count']:
-            channel_message['new_count'] = 0
-        channel_message['new_count'] += 1
-        await self.services.channel_message.save(channel_message)
+        
+        
         user = await self.services.user.get(uid=user_uid)
         await self.services.notification.create_channel_message(channel_message_uid)
         sent_to_count = await self.services.socket.broadcast(channel_uid, dict(
diff --git a/src/snek/service/notification.py b/src/snek/service/notification.py
index 6db762c..a703f23 100644
--- a/src/snek/service/notification.py
+++ b/src/snek/service/notification.py
@@ -36,6 +36,11 @@ class NotificationService(BaseService):
             is_muted=False,
             deleted_at=None,
         ):
+            if not channel_member['new_count']:
+                channel_member['new_count'] = 0
+            channel_member['new_count'] += 1
+            await self.services.channel_member.save(channel_member)
+            
             model = await self.new()
             model["object_uid"] = channel_message_uid
             model["object_type"] = "channel_message"