From 8704cf46ab0e3f1d7974559e85deacb4b31b1962 Mon Sep 17 00:00:00 2001 From: iqeq1945 Date: Tue, 3 Dec 2024 17:44:18 +0900 Subject: [PATCH] fix : error code --- src/room/room.service.ts | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) diff --git a/src/room/room.service.ts b/src/room/room.service.ts index 0db4bf7..7b81445 100644 --- a/src/room/room.service.ts +++ b/src/room/room.service.ts @@ -87,7 +87,7 @@ export class RoomService { async findById(id: string): Promise { try { - return await this.prisma.room.findUnique({ + let room = await this.prisma.room.findUnique({ where: { id }, include: { users: { @@ -102,6 +102,10 @@ export class RoomService { }, }, }); + if (room.users.length === 1 && room.start) { + room = await this.setStart(room.id, false); + } + return room; } catch (error) { if (error instanceof NotFoundException) throw error; throw new BadRequestException('방을 찾는 중 오류가 발생했습니다.');