diff --git a/apiserver/plane/api/views/notification.py b/apiserver/plane/api/views/notification.py index b7f5bd335..83fe0a9aa 100644 --- a/apiserver/plane/api/views/notification.py +++ b/apiserver/plane/api/views/notification.py @@ -6,6 +6,7 @@ from django.utils import timezone from rest_framework import status from rest_framework.response import Response from sentry_sdk import capture_exception +from plane.utils.paginator import BasePaginator # Module imports from .base import BaseViewSet, BaseAPIView @@ -13,7 +14,7 @@ from plane.db.models import Notification, IssueAssignee, IssueSubscriber, Issue from plane.api.serializers import NotificationSerializer -class NotificationViewSet(BaseViewSet): +class NotificationViewSet(BaseViewSet, BasePaginator): model = Notification serializer_class = NotificationSerializer @@ -83,6 +84,16 @@ class NotificationViewSet(BaseViewSet): ).values_list("pk", flat=True) notifications = notifications.filter(entity_identifier__in=issue_ids) + # Pagination + if request.GET.get("per_page", False) and request.GET.get("cursor", False): + return self.paginate( + request=request, + queryset=(notifications), + on_results=lambda notifications: NotificationSerializer( + notifications, many=True + ).data, + ) + serializer = NotificationSerializer(notifications, many=True) return Response(serializer.data, status=status.HTTP_200_OK) except Exception as e: