diff --git a/backend/src/bundles/videos/video.repository.ts b/backend/src/bundles/videos/video.repository.ts index 656af139f..8e56b2730 100644 --- a/backend/src/bundles/videos/video.repository.ts +++ b/backend/src/bundles/videos/video.repository.ts @@ -1,13 +1,19 @@ import { type UpdateVideoRequestDto } from '~/bundles/videos/types/types.js'; import { VideoEntity } from '~/bundles/videos/video.entity.js'; import { type VideoModel } from '~/bundles/videos/video.model.js'; +import { type ImageService } from '~/common/services/image/image.service.js'; import { type Repository } from '~/common/types/types.js'; class VideoRepository implements Repository { private videoModel: typeof VideoModel; + private imageService: ImageService; - public constructor(videoModel: typeof VideoModel) { + public constructor( + videoModel: typeof VideoModel, + imageService: ImageService, + ) { this.videoModel = videoModel; + this.imageService = imageService; } public async findById(id: string): Promise { @@ -58,7 +64,9 @@ class VideoRepository implements Repository { if (payload.composition) { data.composition = payload.composition; - data.previewUrl = payload.composition.scenes[0]?.avatar?.url ?? ''; + data.previewUrl = await this.imageService.generatePreview( + payload.composition, + ); } if (payload.name) { diff --git a/backend/src/bundles/videos/videos.ts b/backend/src/bundles/videos/videos.ts index adb063902..6c9ee5c8a 100644 --- a/backend/src/bundles/videos/videos.ts +++ b/backend/src/bundles/videos/videos.ts @@ -6,7 +6,7 @@ import { VideoModel } from './video.model.js'; import { VideoRepository } from './video.repository.js'; import { VideoService } from './video.service.js'; -const videoRepository = new VideoRepository(VideoModel); +const videoRepository = new VideoRepository(VideoModel, imageService); const videoService = new VideoService( videoRepository, fileService,