so i implemented user blocking but something about the flow in the frontend is broken now, will investigate

This commit is contained in:
Me
2022-12-23 19:49:25 +01:00
parent beeaf1fb27
commit 139da075da
3 changed files with 169 additions and 162 deletions

View File

@@ -62,18 +62,15 @@ export class FriendshipController {
@Patch('myfriends/:relationshipId/accept')
@UseGuards(AuthenticateGuard)
@UseGuards(TwoFactorGuard)
updateAccept(@Param('relationshipId') relationshipId: string, @Req() req)
{
updateAccept(@Param('relationshipId') relationshipId: string, @Req() req) {
const user : User = req.user;
console.log('accepting a friendship BBBBBBBBBBBBBBBBBBBBBBB')
return this.friendshipService.acceptFriendship(relationshipId, user);
}
@Patch('myfriends/:relationshipId/decline')
@UseGuards(AuthenticateGuard)
@UseGuards(TwoFactorGuard)
updateDecline(@Param('relationshipId') relationshipId: string, @Req() req)
{
updateDecline(@Param('relationshipId') relationshipId: string, @Req() req) {
const user : User = req.user;
return this.friendshipService.declineFriendship(relationshipId, user);
}
@@ -81,8 +78,7 @@ export class FriendshipController {
@Patch('myfriends/:relationshipId/block')
@UseGuards(AuthenticateGuard)
@UseGuards(TwoFactorGuard)
updateBlock(@Param('relationshipId') relationshipId: string, @Req() req)
{
updateBlock(@Param('relationshipId') relationshipId: string, @Req() req) {
const user : User = req.user;
return this.friendshipService.blockFriendship(relationshipId, user);
}

View File

@@ -71,7 +71,6 @@ export class FriendshipService {
return friendship;
}
// ERIC: test this
async findAllFriends(username: string) {
const friendship = await this.friendshipRepository
.createQueryBuilder('friendship')
@@ -80,8 +79,8 @@ export class FriendshipService {
.orWhere('friendship.senderUsername = :requester', { requester: username })
.andWhere('friendship.status = :status', { status: FriendshipStatus.ACCEPTED })
.getMany();
for (const friend of friendship)
console.log("FRIENDSHIP : " + friend.status);
// for (const friend of friendship)
// console.log("FRIENDSHIP : " + friend.status);
return friendship;
}
@@ -204,7 +203,7 @@ export class FriendshipService {
}
async blockFriendship(relationshipId: string, user: User) {
const relation = await this.friendshipRepository.find({where: {id: +relationshipId }, relations: ['sender', 'receiver']} );
let relation = await this.friendshipRepository.find({where: {id: +relationshipId }, relations: ['sender', 'receiver']} );
if (!relation[0])
throw new HttpException(`The requested relationship not found.`, HttpStatus.NOT_FOUND);
if (relation[0].sender.id === user.id) {