MCPcopy Create free account
hub / github.com/Dispatcharr/Dispatcharr / list

Method list

core/api_views.py:646–666  ·  view source on GitHub ↗

List all active notifications for the current user. Optionally filter by dismissed status.

(self, request)

Source from the content-addressed store, hash-verified

644 return context
645
646 def list(self, request):
647 """
648 List all active notifications for the current user.
649 Optionally filter by dismissed status.
650 """
651 queryset = self.get_queryset()
652
653 # Optional: filter out already dismissed notifications
654 include_dismissed = request.query_params.get('include_dismissed', 'false').lower() == 'true'
655 if not include_dismissed:
656 dismissed_ids = NotificationDismissal.objects.filter(
657 user=request.user
658 ).values_list('notification_id', flat=True)
659 queryset = queryset.exclude(id__in=dismissed_ids)
660
661 serializer = self.get_serializer(queryset, many=True)
662 return Response({
663 'notifications': serializer.data,
664 'count': len(serializer.data),
665 'unread_count': queryset.count()
666 })
667
668 @action(detail=True, methods=['post'], url_path='dismiss')
669 def dismiss(self, request, pk=None):

Callers

nothing calls this directly

Calls 3

get_querysetMethod · 0.95
getMethod · 0.45
filterMethod · 0.45

Tested by

no test coverage detected