Skip to content

Commit 501b067

Browse files
committedSep 26, 2024
OV-423: * pass scene instead of composition
1 parent 163b7bf commit 501b067

File tree

5 files changed

+13
-8
lines changed

5 files changed

+13
-8
lines changed
 

‎backend/src/bundles/videos/types/types.ts

+1
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,6 @@
11
export {
22
type CreateVideoRequestDto,
3+
type Scene,
34
type UpdateVideoRequestDto,
45
type UserGetCurrentResponseDto,
56
type VideoGetAllItemResponseDto,

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

+5-2
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,7 @@
1-
import { type UpdateVideoRequestDto } from '~/bundles/videos/types/types.js';
1+
import {
2+
type Scene,
3+
type UpdateVideoRequestDto,
4+
} from '~/bundles/videos/types/types.js';
25
import { VideoEntity } from '~/bundles/videos/video.entity.js';
36
import { type VideoModel } from '~/bundles/videos/video.model.js';
47
import { type ImageService } from '~/common/services/image/image.service.js';
@@ -65,7 +68,7 @@ class VideoRepository implements Repository {
6568
if (payload.composition) {
6669
data.composition = payload.composition;
6770
data.previewUrl = await this.imageService.generatePreview(
68-
payload.composition,
71+
payload.composition.scenes[0] as Scene,
6972
);
7073
}
7174

‎backend/src/bundles/videos/video.service.ts

+2-1
Original file line numberDiff line numberDiff line change
@@ -8,6 +8,7 @@ import { type Service } from '~/common/types/types.js';
88
import { VideoValidationMessage } from './enums/enums.js';
99
import {
1010
type CreateVideoRequestDto,
11+
type Scene,
1112
type UpdateVideoRequestDto,
1213
type VideoGetAllItemResponseDto,
1314
type VideoGetAllResponseDto,
@@ -61,7 +62,7 @@ class VideoService implements Service {
6162
payload: CreateVideoRequestDto & { userId: string },
6263
): Promise<VideoGetAllItemResponseDto> {
6364
const previewUrl = await this.imageService.generatePreview(
64-
payload.composition,
65+
payload.composition.scenes[0] as Scene,
6566
);
6667

6768
const video = await this.videoRepository.create(

‎backend/src/common/services/image/image.service.ts

+4-4
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@ import { type FileService } from '~/common/services/file/file.service.js';
44

55
import { PREVIEW_HEIGHT, PREVIEW_WIDTH } from './constants/constants.js';
66
import { type ImageApi } from './image-base.js';
7-
import { type Composition } from './types/types.js';
7+
import { type Scene } from './types/types.js';
88

99
type Constructor = {
1010
fileService: FileService;
@@ -20,9 +20,9 @@ class ImageService {
2020
this.imageApi = imageApi;
2121
}
2222

23-
public async generatePreview(composition: Composition): Promise<string> {
24-
const avatarImage = composition.scenes[0]?.avatar?.url ?? '';
25-
const background = composition.scenes[0]?.background;
23+
public async generatePreview(scene: Scene): Promise<string> {
24+
const avatarImage = scene.avatar?.url ?? '';
25+
const background = scene.background;
2626

2727
if (background?.url) {
2828
const backgroundImageBuffer = await this.imageApi.getImageBuffer(
Original file line numberDiff line numberDiff line change
@@ -1 +1 @@
1-
export { type Composition } from 'shared';
1+
export { type Scene } from 'shared';

0 commit comments

Comments
 (0)