ajout de deux fonctions afin de trouver une relation amicale ou non via le username de ladite relation
This commit is contained in:
@@ -30,6 +30,14 @@ export class FriendshipController {
|
||||
return this.friendshipService.findOneFriend(relationshipId, user.username);
|
||||
}
|
||||
|
||||
@Get('myfriends/:friendUsername')
|
||||
@UseGuards(AuthenticateGuard)
|
||||
@UseGuards(TwoFactorGuard)
|
||||
findOneRelationByUsername(@Param('friendUsername') friendUsername : string, @Req() req) {
|
||||
const user = req.user;
|
||||
return this.friendshipService.findOneFriendByUsername(friendUsername, user.username);
|
||||
}
|
||||
|
||||
// GET http://transcendance:8080/api/v2/network/blocked
|
||||
@Get('blocked')
|
||||
@UseGuards(AuthenticateGuard)
|
||||
|
||||
@@ -23,6 +23,17 @@ export class FriendshipService {
|
||||
return friendship;
|
||||
}
|
||||
|
||||
async findOneFriendByUsername(friendUsername : string, username : string) {
|
||||
const friendship = await this.friendshipRepository
|
||||
.createQueryBuilder('friendship')
|
||||
.where('friendship.senderUsername = : username', {username : username})
|
||||
.andWhere('friendship.receiverUsername = : friendUsername', {friendUsername : friendUsername})
|
||||
.andWhere('friendship.status = : status ', {status : FriendshipStatus.REQUESTED})
|
||||
.orWhere('friendship.status = : status ', {status : FriendshipStatus.ACCEPTED})
|
||||
.getOne()
|
||||
return friendship;
|
||||
}
|
||||
|
||||
async findOneBlocked(friendshipId: string, username: string) {
|
||||
const friendship = await this.friendshipRepository.find({ where: { id: +friendshipId, senderUsername: username, status: FriendshipStatus.BLOCKED } });
|
||||
if (!friendship)
|
||||
@@ -30,6 +41,16 @@ export class FriendshipService {
|
||||
return friendship;
|
||||
}
|
||||
|
||||
async findOneBlockedByUsername(blockedUsername : string, username : string) {
|
||||
const friendship = await this.friendshipRepository
|
||||
.createQueryBuilder('friendship')
|
||||
.where('friendship.senderUsername = : username', {username : username})
|
||||
.andWhere('friendship.receiverUsername = : friendUsername', {friendUsername : blockedUsername})
|
||||
.andWhere('friendship.status = : status ', {status : FriendshipStatus.BLOCKED})
|
||||
.getOne()
|
||||
return friendship;
|
||||
}
|
||||
|
||||
async findAllFriends(username: string) {
|
||||
const friendship = await this.friendshipRepository
|
||||
.createQueryBuilder('friendship')
|
||||
|
||||
Reference in New Issue
Block a user