From 9384d1b1c6637d0570bf28c3a20c3bc595bfb153 Mon Sep 17 00:00:00 2001 From: sedeve Date: Fri, 20 Oct 2023 10:33:19 +0100 Subject: [PATCH] fix: list rooms --- backend/code/src/rooms/dto/list-rooms.dto.ts | 6 +++--- backend/code/src/rooms/rooms.service.ts | 17 ++++++++++++++++- 2 files changed, 19 insertions(+), 4 deletions(-) diff --git a/backend/code/src/rooms/dto/list-rooms.dto.ts b/backend/code/src/rooms/dto/list-rooms.dto.ts index 9bfee18..3ed8970 100644 --- a/backend/code/src/rooms/dto/list-rooms.dto.ts +++ b/backend/code/src/rooms/dto/list-rooms.dto.ts @@ -1,5 +1,5 @@ import { ApiProperty } from '@nestjs/swagger'; -import { Type } from 'class-transformer'; +import { Transform } from 'class-transformer'; import { IsBoolean, IsOptional } from 'class-validator'; import { QueryOffsetDto } from 'src/friends/dto/query-ofsset-dto'; @@ -7,6 +7,6 @@ export class ListRoomsDto extends QueryOffsetDto { @ApiProperty({ required: false }) @IsOptional() @IsBoolean() - @Type(() => Boolean) - joined: boolean; + @Transform(({ value }) => value === 'true') + joined: boolean = false; } diff --git a/backend/code/src/rooms/rooms.service.ts b/backend/code/src/rooms/rooms.service.ts index 7359f58..f0bb1c3 100644 --- a/backend/code/src/rooms/rooms.service.ts +++ b/backend/code/src/rooms/rooms.service.ts @@ -252,8 +252,23 @@ export class RoomsService { async muteMember(roomData: ChangeOwnerDto, userId: string) { const room = await this.prisma.room.findUnique({ where: { id: roomData.roomId }, - select: { ownerId: true }, + select: { + ownerId: true, + members: { + where: { + OR: [ + { + userId: roomData.memberId, + }, + { + userId: userId, + }, + ], + }, + }, + }, }); + //NOTE: check members content const user = await this.prisma.roomMember.findUnique({ where: { unique_user_room: { userId: userId, roomId: roomData.roomId } }, });