feat: enhance collaboration session and LiveKit integration
- Added LiveKitRoomService to manage meeting room creation and recording functionalities. - Updated CollaborationSessionSchema to create a LiveKit room upon new collaboration session creation. - Introduced meetingRoomJoinInfo field in MeetingRoomSchema to provide join tokens and server URLs for meeting rooms. - Improved LiveKitService to include user metadata in token generation and added a method to retrieve the server URL. - Enhanced error handling and authorization checks across schemas to ensure proper access control for collaboration sessions and meeting rooms.
This commit is contained in:
@@ -2,10 +2,11 @@ import { Module } from '@nestjs/common'
|
||||
import { CollaborationSessionSchema } from './collaborationsession.schema'
|
||||
import { LiveKitModule } from 'src/LiveKit/livekit.module'
|
||||
import { LiveKitService } from 'src/LiveKit/livekit.service'
|
||||
import { LiveKitRoomService } from 'src/LiveKit/livekit.room.service'
|
||||
|
||||
@Module({
|
||||
imports: [LiveKitModule],
|
||||
providers: [CollaborationSessionSchema, LiveKitService],
|
||||
providers: [CollaborationSessionSchema, LiveKitService, LiveKitRoomService],
|
||||
exports: [CollaborationSessionSchema],
|
||||
})
|
||||
export class CollaborationSessionModule {}
|
||||
|
||||
@@ -6,12 +6,14 @@ import { Builder, SchemaContext } from 'src/Graphql/graphql.builder'
|
||||
import { PrismaService } from 'src/Prisma/prisma.service'
|
||||
import { DateTimeUtils } from 'src/common/utils/datetime.utils'
|
||||
import { LiveKitService } from 'src/LiveKit/livekit.service'
|
||||
import { LiveKitRoomService } from 'src/LiveKit/livekit.room.service'
|
||||
@Injectable()
|
||||
export class CollaborationSessionSchema extends PothosSchema {
|
||||
constructor(
|
||||
@Inject(SchemaBuilderToken) private readonly builder: Builder,
|
||||
private readonly prisma: PrismaService,
|
||||
private readonly liveKitService: LiveKitService,
|
||||
private readonly liveKitRoomService: LiveKitRoomService,
|
||||
) {
|
||||
super()
|
||||
}
|
||||
@@ -101,11 +103,7 @@ export class CollaborationSessionSchema extends PothosSchema {
|
||||
// }
|
||||
|
||||
// check if user is participant
|
||||
if (
|
||||
!collaborationSession.collaboratorsIds.includes(ctx.http.me.id) ||
|
||||
ctx.http.me.id === 'user_2nkDilSYEiljIraFGF9PENjILPr'
|
||||
)
|
||||
throw new Error('User not allowed')
|
||||
if (!collaborationSession.collaboratorsIds.includes(ctx.http.me.id)) throw new Error('User not allowed')
|
||||
return collaborationSession
|
||||
}
|
||||
/* ---------- use case 2 : center mentor get collaboration session by schedule date id --------- */
|
||||
@@ -164,6 +162,14 @@ export class CollaborationSessionSchema extends PothosSchema {
|
||||
},
|
||||
})
|
||||
}
|
||||
// create meeting room
|
||||
const meetingRoom = await this.prisma.meetingRoom.create({
|
||||
data: {
|
||||
collaborationSessionId: newCollaborationSession.id,
|
||||
},
|
||||
})
|
||||
// create livekit room
|
||||
await this.liveKitRoomService.createServiceMeetingRoom(meetingRoom.id)
|
||||
return newCollaborationSession // if not exist use case
|
||||
}
|
||||
return collaborationSession // if exist use case
|
||||
|
||||
Reference in New Issue
Block a user