feat: add record URL retrieval to MeetingRoom schema and enhance MinioService
- Introduced a new field `recordUrl` in the MeetingRoom schema to fetch the presigned URL for meeting room recordings. - Implemented `getRoomRecordUrl` method in MinioService to retrieve the recording URL from Minio, enhancing the service's functionality. - Updated imports in MeetingRoom schema to include MinioService for the new functionality.
This commit is contained in:
@@ -1,14 +1,16 @@
|
||||
import { Inject, Injectable } from '@nestjs/common'
|
||||
import { Inject, Injectable, Logger } from '@nestjs/common'
|
||||
import { Pothos, PothosRef, PothosSchema, SchemaBuilderToken } from '@smatch-corp/nestjs-pothos'
|
||||
import { Builder, SchemaContext } from 'src/Graphql/graphql.builder'
|
||||
import { PrismaService } from 'src/Prisma/prisma.service'
|
||||
import { LiveKitService } from 'src/LiveKit/livekit.service'
|
||||
import { MinioService } from 'src/Minio/minio.service'
|
||||
@Injectable()
|
||||
export class MeetingRoomSchema extends PothosSchema {
|
||||
constructor(
|
||||
@Inject(SchemaBuilderToken) private readonly builder: Builder,
|
||||
private readonly prisma: PrismaService,
|
||||
private readonly livekitService: LiveKitService,
|
||||
private readonly minioService: MinioService,
|
||||
) {
|
||||
super()
|
||||
}
|
||||
@@ -22,6 +24,12 @@ export class MeetingRoomSchema extends PothosSchema {
|
||||
collaborators: t.relation('collaborators'),
|
||||
createdAt: t.expose('createdAt', { type: 'DateTime' }),
|
||||
updatedAt: t.expose('updatedAt', { type: 'DateTime' }),
|
||||
recordUrl: t.string({
|
||||
nullable: true,
|
||||
resolve: async (meetingRoom) => {
|
||||
return await this.minioService.getRoomRecordUrl(meetingRoom.id)
|
||||
},
|
||||
}),
|
||||
}),
|
||||
})
|
||||
}
|
||||
|
||||
@@ -123,10 +123,6 @@ export class MinioService {
|
||||
})
|
||||
})
|
||||
}
|
||||
|
||||
listRecords(roomId: string) {
|
||||
return this.minioClient.listObjects(this.configService.get('BUCKET_NAME') ?? 'epess', `epess/records/${roomId}`)
|
||||
}
|
||||
// export document to docx format by get all pages and convert to docx
|
||||
async exportDocument(id: string) {
|
||||
// get all pages
|
||||
@@ -141,4 +137,22 @@ export class MinioService {
|
||||
// generate a unique file name using uuid
|
||||
return uuidv4()
|
||||
}
|
||||
// get the record url from minio by searching for the file starting with roomId and ending with .mp4 and returning the presigned url
|
||||
async getRoomRecordUrl(roomId: string) {
|
||||
return new Promise<string | null>(async (resolve, reject) => {
|
||||
const stream = this.minioClient.listObjects(this.configService.get('BUCKET_NAME') ?? 'epess', `records/${roomId}`, true)
|
||||
const items: BucketItem[] = []
|
||||
|
||||
stream.on('data', (item) => {
|
||||
items.push(item)
|
||||
})
|
||||
stream.on('end', async () => {
|
||||
const record = items.find((item) => item.name?.endsWith('.mp4'))
|
||||
resolve(record ? await this.minioClient.presignedUrl('GET', this.configService.get('BUCKET_NAME') ?? 'epess', record.name ?? '') : null)
|
||||
})
|
||||
stream.on('error', (err) => {
|
||||
reject(err)
|
||||
})
|
||||
})
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user