Skip to content

Commit

Permalink
OV-423: * generate preview on update
Browse files Browse the repository at this point in the history
  • Loading branch information
Sanchousina committed Sep 25, 2024
1 parent 0dcaca9 commit 163b7bf
Show file tree
Hide file tree
Showing 2 changed files with 11 additions and 3 deletions.
12 changes: 10 additions & 2 deletions backend/src/bundles/videos/video.repository.ts
Original file line number Diff line number Diff line change
@@ -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<VideoEntity | null> {
Expand Down Expand Up @@ -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) {
Expand Down
2 changes: 1 addition & 1 deletion backend/src/bundles/videos/videos.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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,
Expand Down

0 comments on commit 163b7bf

Please sign in to comment.