Skip to content

Commit 6be9648

Browse files
committed
feat: close previously opened room
1 parent de1462f commit 6be9648

1 file changed

Lines changed: 11 additions & 0 deletions

File tree

src/modules/call/call.usecase.ts

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -26,6 +26,17 @@ export class CallUseCase {
2626
async createCallAndRoom(
2727
user: User | UserTokenData['payload'],
2828
): Promise<CreateCallResponseDto> {
29+
const activeRoom = await this.roomService.getOpenRoomByHostId(user.uuid);
30+
31+
// TODO: Remove this check and look for a better way to handle this
32+
if (activeRoom) {
33+
this.logger.warn(
34+
{ userId: user.uuid, roomId: activeRoom.id },
35+
`User already has an active room as host, closing previous room`,
36+
);
37+
await this.roomService.removeRoom(activeRoom.id);
38+
}
39+
2940
await this.validateUserHasNoActiveRoom(user.uuid, user.email);
3041

3142
const call = await this.callService.createCallToken(user);

0 commit comments

Comments
 (0)