feat: integrate LiveKit services into Collaboration and Meeting Room modules
- Added LiveKitModule to CollaborationSession and MeetingRoom modules for enhanced real-time collaboration features. - Updated CollaborationSessionSchema to include LiveKit services for managing participant access and room permissions. - Implemented a new cron job in CronService to disable services without schedules for over 30 days, improving service management. - Enhanced GraphQL schema generation with improved filtering logic for better performance and readability. - Refactored LiveKit services to streamline access token creation and room management functionalities.
This commit is contained in:
@@ -1,7 +1,10 @@
|
||||
// import { Module } from '@nestjs/common'
|
||||
// import { LiveKitService } from './livekit.service'
|
||||
// @Module({
|
||||
// providers: [LiveKitService],
|
||||
// exports: [LiveKitService],
|
||||
// })
|
||||
// export class LiveKitModule {}
|
||||
import { Module } from '@nestjs/common'
|
||||
import { LiveKitService } from './livekit.service'
|
||||
import { LiveKitParticipantService } from './livekit.participant.service'
|
||||
import { LiveKitRoomService } from './livekit.room.service'
|
||||
|
||||
@Module({
|
||||
providers: [LiveKitService, LiveKitParticipantService, LiveKitRoomService],
|
||||
exports: [LiveKitService],
|
||||
})
|
||||
export class LiveKitModule {}
|
||||
|
||||
@@ -5,13 +5,9 @@ import { AccessToken } from 'livekit-server-sdk'
|
||||
@Injectable()
|
||||
export class LiveKitParticipantService {
|
||||
async createAccessToken(participantId: string) {
|
||||
return new AccessToken(
|
||||
process.env.LIVEKIT_API_KEY,
|
||||
process.env.LIVEKIT_API_SECRET,
|
||||
{
|
||||
identity: participantId,
|
||||
},
|
||||
)
|
||||
return new AccessToken(process.env.LIVEKIT_API_KEY as string, process.env.LIVEKIT_API_SECRET as string, {
|
||||
identity: participantId,
|
||||
})
|
||||
}
|
||||
|
||||
async grantRoomJoinPermission(token: AccessToken, roomName: string) {
|
||||
|
||||
@@ -1,36 +1,35 @@
|
||||
// import {
|
||||
// Room,
|
||||
// RoomServiceClient,
|
||||
// RoomCompositeOptions,
|
||||
// // @ts-ignore
|
||||
// } from 'livekit-server-sdk'
|
||||
// import { v4 as uuidv4 } from 'uuid'
|
||||
import { v4 as uuidv4 } from 'uuid'
|
||||
|
||||
// export class LiveKitRoomService {
|
||||
// private roomServiceClient: RoomServiceClient
|
||||
export class LiveKitRoomService {
|
||||
// biome-ignore lint/suspicious/noExplicitAny: <explanation>
|
||||
private roomServiceClient: any
|
||||
constructor() {
|
||||
this.initializeRoomServiceClient()
|
||||
}
|
||||
|
||||
// constructor() {
|
||||
// this.roomServiceClient = new RoomServiceClient(
|
||||
// process.env.LIVEKIT_URL as string,
|
||||
// process.env.LIVEKIT_API_KEY as string,
|
||||
// process.env.LIVEKIT_API_SECRET as string,
|
||||
// )
|
||||
// }
|
||||
private async initializeRoomServiceClient() {
|
||||
const { RoomServiceClient } = await import('livekit-server-sdk')
|
||||
this.roomServiceClient = new RoomServiceClient(
|
||||
process.env.LIVEKIT_URL as string,
|
||||
process.env.LIVEKIT_API_KEY as string,
|
||||
process.env.LIVEKIT_API_SECRET as string,
|
||||
)
|
||||
}
|
||||
|
||||
// async createServiceMeetingRoom(chattingRoomId: string) {
|
||||
// const room = await this.roomServiceClient.createRoom({
|
||||
// maxParticipants: 3,
|
||||
// name: chattingRoomId,
|
||||
// })
|
||||
async createServiceMeetingRoom(chattingRoomId: string) {
|
||||
const room = await this.roomServiceClient.createRoom({
|
||||
maxParticipants: 3,
|
||||
name: chattingRoomId,
|
||||
})
|
||||
|
||||
// return room
|
||||
// }
|
||||
return room
|
||||
}
|
||||
|
||||
// async createWorkshopMeetingRoom(workshopId: string, maxParticipants: number) {
|
||||
// const room = await this.roomServiceClient.createRoom({
|
||||
// maxParticipants: maxParticipants,
|
||||
// name: workshopId,
|
||||
// })
|
||||
// return room
|
||||
// }
|
||||
// }
|
||||
async createWorkshopMeetingRoom(workshopId: string, maxParticipants: number) {
|
||||
const room = await this.roomServiceClient.createRoom({
|
||||
maxParticipants: maxParticipants,
|
||||
name: workshopId,
|
||||
})
|
||||
return room
|
||||
}
|
||||
}
|
||||
|
||||
@@ -1,11 +1,15 @@
|
||||
// import { Injectable, OnModuleInit } from '@nestjs/common'
|
||||
// import { LiveKitRoomService } from './livekit.room.service'
|
||||
import { Injectable } from '@nestjs/common'
|
||||
import { LiveKitRoomService } from './livekit.room.service'
|
||||
import { LiveKitParticipantService } from './livekit.participant.service'
|
||||
|
||||
// @Injectable()
|
||||
// export class LiveKitService implements OnModuleInit {
|
||||
// private liveKitRoomService: LiveKitRoomService
|
||||
// async onModuleInit() {
|
||||
// // init livekit room service
|
||||
// this.liveKitRoomService = new LiveKitRoomService()
|
||||
// }
|
||||
// }
|
||||
@Injectable()
|
||||
export class LiveKitService {
|
||||
constructor(
|
||||
private liveKitRoomService: LiveKitRoomService,
|
||||
private liveKitParticipantService: LiveKitParticipantService,
|
||||
) {}
|
||||
|
||||
async createAccessToken(participantId: string) {
|
||||
return await this.liveKitParticipantService.createAccessToken(participantId)
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user