From f7e51e39d2213e22c09dbae6cda9124f5852eb34 Mon Sep 17 00:00:00 2001 From: vvandenb Date: Tue, 21 Mar 2023 09:42:38 +0100 Subject: [PATCH] * last --- back/volume/src/chat/chat.controller.ts | 24 ++++++++++++------------ back/volume/src/main.ts | 1 - 2 files changed, 12 insertions(+), 13 deletions(-) diff --git a/back/volume/src/chat/chat.controller.ts b/back/volume/src/chat/chat.controller.ts index bac2c0f..019f073 100644 --- a/back/volume/src/chat/chat.controller.ts +++ b/back/volume/src/chat/chat.controller.ts @@ -140,25 +140,25 @@ export class ChatController { @Profile42() profile: Profile ): Promise { const channel = await this.channelService.getFullChannel(id) - const user: User | null = await this.usersService.findUser(target.data[0]) + const user: User | null = await this.usersService.findUser(+target.data[0]) if (isNaN(+target.data[1])) { - throw new BadRequestException(`Invalid duration ${target.data[1]}`) + throw new BadRequestException(`Invalid duration ${+target.data[1]}`) } if (user == null) { - throw new NotFoundException(`User #${target.data[0]} not found`) + throw new NotFoundException(`User #${+target.data[0]} not found`) } if (!(await this.channelService.isAdmin(channel.id, +profile.id))) { throw new BadRequestException( 'You are not allowed to ban users from this channel' ) } - if (await this.channelService.isOwner(channel.id, target.data[0])) { + if (await this.channelService.isOwner(channel.id, +target.data[0])) { throw new BadRequestException('You cannot ban the owner of the channel') } - if (await this.channelService.isBanned(channel.id, target.data[0])) { + if (await this.channelService.isBanned(channel.id, +target.data[0])) { throw new BadRequestException('User is already banned from this channel') } - channel.banned.push([target.data[0], Date.now() + target.data[1] * 1000]) + channel.banned.push([+target.data[0], Date.now() + +target.data[1] * 1000]) await this.channelService.save(channel) } @@ -169,25 +169,25 @@ export class ChatController { @Profile42() profile: Profile ): Promise { const channel = await this.channelService.getFullChannel(id) - const user: User | null = await this.usersService.findUser(mute.data[0]) + const user: User | null = await this.usersService.findUser(+mute.data[0]) if (isNaN(+mute.data[1])) { - throw new BadRequestException(`Invalid duration ${mute.data[1]}`) + throw new BadRequestException(`Invalid duration ${+mute.data[1]}`) } if (user == null) { - throw new NotFoundException(`User #${mute.data[0]} not found`) + throw new NotFoundException(`User #${+mute.data[0]} not found`) } if (!(await this.channelService.isAdmin(channel.id, +profile.id))) { throw new BadRequestException( 'You are not allowed to mute users from this channel' ) } - if (await this.channelService.isOwner(channel.id, mute.data[0])) { + if (await this.channelService.isOwner(channel.id, +mute.data[0])) { throw new BadRequestException('You cannot mute the owner of the channel') } - if (await this.channelService.isMuted(channel.id, mute.data[0])) { + if (await this.channelService.isMuted(channel.id, +mute.data[0])) { throw new BadRequestException('User is already muted from this channel') } - const newMute: number[] = [mute.data[0], Date.now() + mute.data[1] * 1000] + const newMute: number[] = [+mute.data[0], Date.now() + +mute.data[1] * 1000] channel.muted.push(newMute) await this.channelService.save(channel) } diff --git a/back/volume/src/main.ts b/back/volume/src/main.ts index 6f9dc7b..105ee22 100644 --- a/back/volume/src/main.ts +++ b/back/volume/src/main.ts @@ -25,7 +25,6 @@ async function bootstrap (): Promise { allowedHeaders: ['Accept', 'Content-Type', 'Authorization'] } - app.useGlobalPipes(new ValidationPipe()) app.use( session({ resave: false,