From 15ea27955b93f1781bf4323765bcc03685e2c267 Mon Sep 17 00:00:00 2001 From: Me Date: Fri, 9 Dec 2022 16:53:00 +0100 Subject: [PATCH] trying to push again --- .../nestjs/api_back/src/friendship/friendship.service.ts | 5 +++-- .../api_front/src/pages/profile/ProfileFriends.svelte | 6 +++--- 2 files changed, 6 insertions(+), 5 deletions(-) diff --git a/srcs/requirements/nestjs/api_back/src/friendship/friendship.service.ts b/srcs/requirements/nestjs/api_back/src/friendship/friendship.service.ts index 348921db..c2f0a164 100644 --- a/srcs/requirements/nestjs/api_back/src/friendship/friendship.service.ts +++ b/srcs/requirements/nestjs/api_back/src/friendship/friendship.service.ts @@ -68,10 +68,11 @@ export class FriendshipService { } //GROS CHANTIER async create(createFriendshipDto: CreateFriendshipDto, creator : User) { - const addressee = await this.userRepository.findOneBy({username: createFriendshipDto.requesterUsername}); + const addressee = await this.userRepository.findOneBy({username: createFriendshipDto.addresseeUsername}); if (!addressee) throw new HttpException(`The addressee does not exist.`, HttpStatus.NOT_FOUND); - if (creator.id === addressee.id) + // console.log('Addressee ID: ' + addressee.id + 'Username: ' + a) + if (creator.id === addressee.id) throw new HttpException(`You can't add yourself.`, HttpStatus.FORBIDDEN); if (createFriendshipDto.status !== FriendshipStatus.REQUESTED && createFriendshipDto.status !== FriendshipStatus.BLOCKED) throw new HttpException(`The status is not valid.`, HttpStatus.NOT_FOUND); diff --git a/srcs/requirements/svelte/api_front/src/pages/profile/ProfileFriends.svelte b/srcs/requirements/svelte/api_front/src/pages/profile/ProfileFriends.svelte index d93b1f0b..14090781 100644 --- a/srcs/requirements/svelte/api_front/src/pages/profile/ProfileFriends.svelte +++ b/srcs/requirements/svelte/api_front/src/pages/profile/ProfileFriends.svelte @@ -103,9 +103,9 @@ method : "POST", headers: { 'Content-Type': 'application/json'}, body: JSON.stringify({ - "requesterId": user.id, - "addresseeId": set.friendId, - "status": r + "requesterUsername": user.username, + "addresseeUsername": set.friendUsername, + "status": "R" }) }) .then( x => x.json())