diff --git a/backend/src/controllers/participant.controller.ts b/backend/src/controllers/participant.controller.ts index 6abbc63..abdd557 100644 --- a/backend/src/controllers/participant.controller.ts +++ b/backend/src/controllers/participant.controller.ts @@ -14,7 +14,6 @@ import { getCookieOptions } from '../utils/cookie-utils.js'; export const generateParticipantToken = async (req: Request, res: Response) => { const logger = container.get(LoggerService); const participantService = container.get(ParticipantService); - const roomService = container.get(RoomService); const participantOptions: ParticipantOptions = req.body; const { roomId } = participantOptions; @@ -40,11 +39,6 @@ export const generateParticipantToken = async (req: Request, res: Response) => { try { logger.verbose(`Generating participant token for room '${roomId}'`); - // If participantName is provided, create the Livekit room if it doesn't exist - if (participantOptions.participantName) { - await roomService.createLivekitRoom(roomId); - } - const token = await participantService.generateOrRefreshParticipantToken(participantOptions, currentRoles); res.cookie(INTERNAL_CONFIG.PARTICIPANT_TOKEN_COOKIE_NAME, token, getCookieOptions('/')); return res.status(200).json({ token }); diff --git a/backend/src/services/participant.service.ts b/backend/src/services/participant.service.ts index c060595..8a70fea 100644 --- a/backend/src/services/participant.service.ts +++ b/backend/src/services/participant.service.ts @@ -52,6 +52,9 @@ export class ParticipantService { throw errorRoomClosed(roomId); } + // Create the Livekit room if it doesn't exist + await this.roomService.createLivekitRoom(roomId); + if (refresh) { if (!participantIdentity) { throw errorParticipantIdentityNotProvided();