mirror of
https://gitlab.com/animath/si/plateforme.git
synced 2024-12-24 18:22:24 +00:00
Linting
Signed-off-by: Emmy D'Anello <emmy.danello@animath.fr>
This commit is contained in:
parent
a41c17576f
commit
ed5944e044
@ -3,7 +3,7 @@
|
||||
|
||||
from channels.generic.websocket import AsyncJsonWebsocketConsumer
|
||||
from django.contrib.auth.models import User
|
||||
from django.db.models import Exists, OuterRef, Count, Q
|
||||
from django.db.models import Count, Exists, OuterRef, Q
|
||||
from registration.models import Registration
|
||||
|
||||
from .models import Channel, Message
|
||||
@ -92,7 +92,7 @@ class ChatConsumer(AsyncJsonWebsocketConsumer):
|
||||
'write_access': await self.write_channels.acontains(channel),
|
||||
'unread_messages': channel.unread_messages,
|
||||
}
|
||||
async for channel in self.read_channels.prefetch_related('invited') \
|
||||
async for channel in self.read_channels.prefetch_related('invited')
|
||||
.annotate(unread_messages=Count('messages', filter=~Q(messages__users_read=user))).all()
|
||||
]
|
||||
}
|
||||
@ -160,7 +160,7 @@ class ChatConsumer(AsyncJsonWebsocketConsumer):
|
||||
|
||||
messages = Message.objects \
|
||||
.filter(channel=channel) \
|
||||
.annotate(read=Exists(User.objects.filter(pk=self.scope['user'].pk) \
|
||||
.annotate(read=Exists(User.objects.filter(pk=self.scope['user'].pk)
|
||||
.filter(pk=OuterRef('users_read')))) \
|
||||
.order_by('-created_at')[offset:offset + limit].all()
|
||||
await self.send_json({
|
||||
|
Loading…
Reference in New Issue
Block a user