forked from mirrors/bookwyrm
24 lines
698 B
Python
24 lines
698 B
Python
""" endpoints for getting updates about activity """
|
|
from django.contrib.auth.decorators import login_required
|
|
from django.http import JsonResponse
|
|
|
|
from bookwyrm import activitystreams
|
|
|
|
|
|
@login_required
|
|
def get_notification_count(request):
|
|
"""any notifications waiting?"""
|
|
return JsonResponse(
|
|
{
|
|
"count": request.user.notification_set.filter(read=False).count(),
|
|
}
|
|
)
|
|
|
|
|
|
@login_required
|
|
def get_unread_status_count(request, stream="home"):
|
|
"""any unread statuses for this feed?"""
|
|
stream = activitystreams.streams.get(stream)
|
|
if not stream:
|
|
return JsonResponse({})
|
|
return JsonResponse({"count": stream.get_unread_count(request.user)})
|