chat ws with pfp is working

This commit is contained in:
David Bruno Vontor
2026-05-28 17:23:04 +02:00
parent f19375254f
commit 8269d044a2
28 changed files with 299 additions and 90 deletions

View File

@@ -1,6 +1,7 @@
from asgiref.sync import async_to_sync
from channels.layers import get_channel_layer
from django.contrib.auth import get_user_model
from django.db.models import Q
from rest_framework import status, viewsets
from rest_framework.decorators import action
from rest_framework.exceptions import PermissionDenied, ValidationError
@@ -49,7 +50,7 @@ class ChatViewSet(viewsets.ModelViewSet):
user = self.request.user
if user.is_superuser:
return Chat.objects.all()
return Chat.objects.filter(members=user)
return Chat.objects.filter(Q(members=user) | Q(owner=user)).distinct()
def perform_create(self, serializer):
serializer.save(owner=self.request.user)