Skip to content

Commit

Permalink
Merge: 채팅방 만들기 오류 수정
Browse files Browse the repository at this point in the history
[inspection] 채팅방 만들기 오류 수정
  • Loading branch information
yyysolhhh authored May 30, 2024
2 parents 232b84c + 7f911f6 commit 5d7f839
Showing 1 changed file with 8 additions and 1 deletion.
9 changes: 8 additions & 1 deletion apps/chat/views.py
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
from django.contrib.auth.models import AnonymousUser
from django.db import transaction
from django.db.models import Q
from django.http import HttpRequest, HttpResponse
Expand Down Expand Up @@ -55,10 +56,16 @@ def get(self, request: Request) -> Response:
""",
)
def post(self, request: Request) -> Response:
if isinstance(request.user, AnonymousUser):
return Response({"msg": "유저 자격증명이 불일치 합니다. 재로그인이 필요합니다."})
product_uuid = request.data.get("product")
lender_id = request.data.get("lender")
if Chatroom.objects.filter(
product=product_uuid, lender_id=lender_id, lender_status=True, borrower_status=True
product=product_uuid,
borrower_id=request.user.id,
lender_id=lender_id,
lender_status=True,
borrower_status=True
).exists():
return Response({"msg": "이미 개설된 채팅방 내역이 존재합니다."}, status=status.HTTP_400_BAD_REQUEST)
serializer = serializers.CreateChatroomSerializer(data=request.data)
Expand Down

0 comments on commit 5d7f839

Please sign in to comment.