Skip to content

Commit 163b7bf

Browse files
committed
OV-423: * generate preview on update
1 parent 0dcaca9 commit 163b7bf

File tree

2 files changed

+11
-3
lines changed

2 files changed

+11
-3
lines changed

backend/src/bundles/videos/video.repository.ts

+10-2
Original file line numberDiff line numberDiff line change
@@ -1,13 +1,19 @@
11
import { type UpdateVideoRequestDto } from '~/bundles/videos/types/types.js';
22
import { VideoEntity } from '~/bundles/videos/video.entity.js';
33
import { type VideoModel } from '~/bundles/videos/video.model.js';
4+
import { type ImageService } from '~/common/services/image/image.service.js';
45
import { type Repository } from '~/common/types/types.js';
56

67
class VideoRepository implements Repository {
78
private videoModel: typeof VideoModel;
9+
private imageService: ImageService;
810

9-
public constructor(videoModel: typeof VideoModel) {
11+
public constructor(
12+
videoModel: typeof VideoModel,
13+
imageService: ImageService,
14+
) {
1015
this.videoModel = videoModel;
16+
this.imageService = imageService;
1117
}
1218

1319
public async findById(id: string): Promise<VideoEntity | null> {
@@ -58,7 +64,9 @@ class VideoRepository implements Repository {
5864

5965
if (payload.composition) {
6066
data.composition = payload.composition;
61-
data.previewUrl = payload.composition.scenes[0]?.avatar?.url ?? '';
67+
data.previewUrl = await this.imageService.generatePreview(
68+
payload.composition,
69+
);
6270
}
6371

6472
if (payload.name) {

backend/src/bundles/videos/videos.ts

+1-1
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,7 @@ import { VideoModel } from './video.model.js';
66
import { VideoRepository } from './video.repository.js';
77
import { VideoService } from './video.service.js';
88

9-
const videoRepository = new VideoRepository(VideoModel);
9+
const videoRepository = new VideoRepository(VideoModel, imageService);
1010
const videoService = new VideoService(
1111
videoRepository,
1212
fileService,

0 commit comments

Comments
 (0)