diff --git a/back/volume/src/pong/pong.service.ts b/back/volume/src/pong/pong.service.ts index b0f8a06..2c59d63 100644 --- a/back/volume/src/pong/pong.service.ts +++ b/back/volume/src/pong/pong.service.ts @@ -20,7 +20,6 @@ export class PongService { if (result.score[i] === maxScore) player.wins++ else player.looses++ player.winrate = (100 * player.wins) / player.matchs - player.rank = (await this.usersService.getRank(player.ftId)) + 1 } async updatePlayer (i: number, result: Result, maxScore: number): Promise { diff --git a/back/volume/src/users/users.service.ts b/back/volume/src/users/users.service.ts index ae2d26e..858d86f 100644 --- a/back/volume/src/users/users.service.ts +++ b/back/volume/src/users/users.service.ts @@ -21,9 +21,7 @@ export class UsersService { async findUsers (): Promise { const users = await this.usersRepository.find({}) - users.forEach((usr) => { - usr.socketKey = '' - }) + users.forEach((usr) => usr.socketKey = '') return users } @@ -33,6 +31,7 @@ export class UsersService { relations: { results: true } }) if (user == null) throw new BadRequestException('User not found.') + user.rank = (await this.getRank(user.ftId)) + 1; return user } @@ -43,9 +42,7 @@ export class UsersService { if (Date.now() - usr.lastAccess > 60000) { usr.isVerified = false usr.status = 'offline' - this.usersRepository.save(usr).catch((err) => { - console.log(err) - }) + this.usersRepository.save(usr).catch((err) => console.log(err)) } }) } @@ -53,6 +50,7 @@ export class UsersService { async findUser (ftId: number): Promise { const user = await this.usersRepository.findOneBy({ ftId }) if (user == null) return null + user.rank = (await this.getRank(user.ftId)) + 1; user.lastAccess = Date.now() if (user.status === 'offline') user.status = 'online' await this.usersRepository.save(user) @@ -63,9 +61,7 @@ export class UsersService { const users = await this.usersRepository.find({ where: { status: 'online' } }) - users.forEach((usr) => { - usr.socketKey = '' - }) + users.forEach((usr) => usr.socketKey = '') return users } @@ -102,6 +98,7 @@ export class UsersService { relations: { friends: true } }) if (user == null) throw new BadRequestException('User not found.') + user.friends.forEach((friend) => friend.socketKey = '') return user.friends } @@ -113,6 +110,7 @@ export class UsersService { } }) if (user == null) throw new BadRequestException('User not found.') + user.followers.forEach((follower) => follower.socketKey = '') return user.followers } @@ -122,7 +120,9 @@ export class UsersService { winrate: 'DESC' } }) - return leaderboard.filter((user) => user.rank !== 0) + let ret = leaderboard.filter((user) => user.rank !== 0) + ret.forEach((follower) => follower.socketKey = '') + return ret } async getRank (ftId: number): Promise { diff --git a/front/volume/src/components/Channels.svelte b/front/volume/src/components/Channels.svelte index eb2e543..cdee9b0 100644 --- a/front/volume/src/components/Channels.svelte +++ b/front/volume/src/components/Channels.svelte @@ -56,8 +56,8 @@ body: JSON.stringify({ name: name, owner: $store.ftId, - password: password || "", - isPrivate: privacy, + password: password, + isPrivate: privacy === "private", }), }); if (response.ok) {