diff --git a/plugins/love-resources/src/utils.ts b/plugins/love-resources/src/utils.ts index db68b04cab..b8295c0ad0 100644 --- a/plugins/love-resources/src/utils.ts +++ b/plugins/love-resources/src/utils.ts @@ -393,7 +393,7 @@ lk.on(RoomEvent.Connected, () => { sendMessage({ type: 'connect', value: true }) isCurrentInstanceConnected.set(true) isRecording.set(lk.isRecording) - initRoomMetadata(lk.metadata) + void initRoomMetadata(lk.metadata) Analytics.handleEvent(LoveEvents.ConnectedToRoom) }) lk.on(RoomEvent.Disconnected, () => { @@ -403,7 +403,7 @@ lk.on(RoomEvent.Disconnected, () => { Analytics.handleEvent(LoveEvents.DisconnectedFromRoom) }) -function initRoomMetadata (metadata: string | undefined): void { +async function initRoomMetadata (metadata: string | undefined): Promise { let data: RoomMetadata try { data = metadata == null || metadata === '' ? {} : JSON.parse(metadata) @@ -420,11 +420,11 @@ function initRoomMetadata (metadata: string | undefined): void { (data.transcription == null || data.transcription === TranscriptionStatus.Idle) && room?.startWithTranscription === true ) { - void startTranscription(room) + await startTranscription(room) } - if (get(isRecordingAvailable) && data.recording == null && room?.startWithRecording === true) { - void record(room) + if (data.recording == null && room?.startWithRecording === true) { + await record(room) } } diff --git a/services/ai-bot/pod-ai-bot/src/workspace/love.ts b/services/ai-bot/pod-ai-bot/src/workspace/love.ts index 18b7edc9c5..78c414ab79 100644 --- a/services/ai-bot/pod-ai-bot/src/workspace/love.ts +++ b/services/ai-bot/pod-ai-bot/src/workspace/love.ts @@ -115,12 +115,8 @@ export class LoveController { } async connect (request: ConnectMeetingRequest): Promise { - if (this.connectedRooms.has(request.roomId)) return - - this.roomSidById.set(request.roomId, request.roomSid) - this.connectedRooms.add(request.roomId) - const room = await this.getRoom(request.roomId) + if (room === undefined) { this.ctx.error('Room not found', request) this.roomSidById.delete(request.roomId) @@ -128,22 +124,23 @@ export class LoveController { return } + this.roomSidById.set(request.roomId, request.roomSid) + this.connectedRooms.add(request.roomId) + this.ctx.info('Connecting', { room: room.name, roomId: room._id }) if (request.transcription) { - const roomTokenName = getTokenRoomName(this.workspace, room.name, room._id) - const isTranscriptionStarted = await startTranscription(this.token, roomTokenName, room.name, request.language) - - if (!isTranscriptionStarted) { - this.roomSidById.delete(request.roomId) - this.connectedRooms.delete(request.roomId) - return - } + await this.requestTranscription(room, request.language) } await this.createAiParticipant(room) } + async requestTranscription (room: Room, language: RoomLanguage): Promise { + const roomTokenName = getTokenRoomName(this.workspace, room.name, room._id) + await startTranscription(this.token, roomTokenName, room.name, language) + } + async disconnect (roomId: Ref): Promise { this.ctx.info('Disconnecting', { roomId })