add Friendrequests

This commit is contained in:
j3d1 2023-06-22 11:44:28 +02:00
parent e447f389d8
commit 0d394d531b
2 changed files with 4 additions and 2 deletions

View file

@ -60,6 +60,8 @@ def verify_incoming_friend_request(request, raw_request_body):
befriender_key = request.data['befriender_key']
except KeyError:
return False
if not befriender or not befriender_key:
return False
if username + "@" + domain != befriender:
return False
if len(befriender_key) != 64:

View file

@ -72,7 +72,7 @@ class FriendsRequests(APIView, ViewSetMixin):
befriender_username=befriender_username,
befriender_domain=befriender_domain,
befriender_public_key=user.public_identity.public_key,
secret=secret, # request.data['secret'] # TODO ??
secret=secret,
befriendee_user=befriendee_user.get(),
)
return Response(status=status.HTTP_201_CREATED, data={'secret': secret, 'status': "pending"})
@ -81,7 +81,7 @@ class FriendsRequests(APIView, ViewSetMixin):
befriender_user=user,
befriendee_username=befriendee_username,
befriendee_domain=befriendee_domain,
secret=secret, # request.data['secret'] # TODO ??
secret=secret,
)
return Response(status=status.HTTP_201_CREATED, data={'secret': secret, 'status': "pending"})
elif verify_incoming_friend_request(request, raw_request):