fix: friend: cannot add yourself

This commit is contained in:
starnakin 2024-04-09 13:57:17 +02:00
parent b4dccfb83e
commit 0127a22a46

View File

@ -35,6 +35,9 @@ class EditFriendView(APIView):
user_profile = self.get_object() user_profile = self.get_object()
friend_profile = get_object_or_404(ProfileModel, pk=pk) friend_profile = get_object_or_404(ProfileModel, pk=pk)
if user_profile.pk == pk:
return Response(_('You can\'t be friend with yourself.'), status.HTTP_400_BAD_REQUEST)
if user_profile.is_friend(friend_profile): if user_profile.is_friend(friend_profile):
return Response(_('You are already friend with this user.'), status.HTTP_400_BAD_REQUEST) return Response(_('You are already friend with this user.'), status.HTTP_400_BAD_REQUEST)