Exclude ignored users in chat

This commit is contained in:
cuom1999 2022-03-10 22:30:58 -06:00
parent bc40d293d6
commit 3bf3754baf

View file

@ -438,9 +438,12 @@ def get_unread_boxes(request):
if (request.method != 'GET'): if (request.method != 'GET'):
return HttpResponseBadRequest() return HttpResponseBadRequest()
ignored_users = Ignore.get_ignored_users(request.profile)
mess = Message.objects.filter(room=OuterRef('room'), mess = Message.objects.filter(room=OuterRef('room'),
time__gte=OuterRef('last_seen'))\ time__gte=OuterRef('last_seen'))\
.exclude(author=request.profile)\ .exclude(author=request.profile)\
.exclude(author__in=ignored_users)\
.order_by().values('room')\ .order_by().values('room')\
.annotate(unread_count=Count('pk')).values('unread_count') .annotate(unread_count=Count('pk')).values('unread_count')