main
py 34 lines 1.15 KB
Raw
1 from helpers.api import ApiHandler
2 from flask import Request, Response
3 from agent import AgentContext
4
5
6 class NotificationsMarkRead(ApiHandler):
7 @classmethod
8 def requires_auth(cls) -> bool:
9 return True
10
11 async def process(self, input: dict, request: Request) -> dict | Response:
12 notification_ids = input.get("notification_ids", [])
13 mark_all = input.get("mark_all", False)
14
15 notification_manager = AgentContext.get_notification_manager()
16
17 if mark_all:
18 notification_manager.mark_all_read()
19 return {"success": True, "message": "All notifications marked as read"}
20
21 if not notification_ids:
22 return {"success": False, "error": "No notification IDs provided"}
23
24 if not isinstance(notification_ids, list):
25 return {"success": False, "error": "notification_ids must be a list"}
26
27 # Mark specific notifications as read
28 marked_count = notification_manager.mark_read_by_ids(notification_ids)
29
30 return {
31 "success": True,
32 "marked_count": marked_count,
33 "message": f"Marked {marked_count} notifications as read"
34 }