Skip to content
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
14 changes: 11 additions & 3 deletions chats/views.py
Original file line number Diff line number Diff line change
Expand Up @@ -117,7 +117,9 @@ def get(self, request, *args, **kwargs) -> Response:
except ValueError:
return Response(
status=status.HTTP_400_BAD_REQUEST,
data={"detail": "processed id must contain two integers separated by underscore"},
data={
"detail": "processed id must contain two integers separated by underscore"
},
)
except AssertionError as e:
return Response(status=status.HTTP_400_BAD_REQUEST, data={"detail": str(e)})
Expand Down Expand Up @@ -223,10 +225,16 @@ def get(self, request, *args, **kwargs):
project_chats = user.get_project_chats().prefetch_related("messages")

has_direct_messages_unread = (
direct_messages.filter(messages__is_read=False).distinct().exists()
direct_messages.filter(messages__is_read=False)
.exclude(messages__is_deleted=True)
.distinct()
.exists()
)
has_project_messages_unread = (
project_chats.filter(messages__is_read=False).distinct().exists()
project_chats.filter(messages__is_read=False)
.exclude(messages__is_deleted=True)
.distinct()
.exists()
)
return Response(
{"has_unreads": has_direct_messages_unread or has_project_messages_unread}
Expand Down