From 8ef7d18c15ae974e0c78f16b79f782f62fd6531e Mon Sep 17 00:00:00 2001 From: Leo Date: Thu, 19 Mar 2020 13:37:41 +0800 Subject: [PATCH] add-delete-user-notification-api (#4485) * add-delete-user-notification-api * update-code --- seahub/api2/endpoints/notifications.py | 16 ++++++++++++++++ 1 file changed, 16 insertions(+) diff --git a/seahub/api2/endpoints/notifications.py b/seahub/api2/endpoints/notifications.py index 296f382d92..17f7ffc33d 100644 --- a/seahub/api2/endpoints/notifications.py +++ b/seahub/api2/endpoints/notifications.py @@ -101,6 +101,22 @@ class NotificationsView(APIView): return Response({'success': True}) + def delete(self, request): + """ delete a notification by username + + Permission checking: + 1. login user. + """ + username = request.user.username + + UserNotification.objects.remove_user_notifications(username) + + cache_key = get_cache_key_of_unseen_notifications(username) + cache.delete(cache_key) + + return Response({'success': True}) + + class NotificationView(APIView):