Skip to content

Commit

Permalink
OV-423: * pass scene instead of composition
Browse files Browse the repository at this point in the history
  • Loading branch information
Sanchousina committed Sep 26, 2024
1 parent 163b7bf commit 501b067
Show file tree
Hide file tree
Showing 5 changed files with 13 additions and 8 deletions.
1 change: 1 addition & 0 deletions backend/src/bundles/videos/types/types.ts
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
export {
type CreateVideoRequestDto,
type Scene,
type UpdateVideoRequestDto,
type UserGetCurrentResponseDto,
type VideoGetAllItemResponseDto,
Expand Down
7 changes: 5 additions & 2 deletions backend/src/bundles/videos/video.repository.ts
Original file line number Diff line number Diff line change
@@ -1,4 +1,7 @@
import { type UpdateVideoRequestDto } from '~/bundles/videos/types/types.js';
import {
type Scene,
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';
Expand Down Expand Up @@ -65,7 +68,7 @@ class VideoRepository implements Repository {
if (payload.composition) {
data.composition = payload.composition;
data.previewUrl = await this.imageService.generatePreview(
payload.composition,
payload.composition.scenes[0] as Scene,
);
}

Expand Down
3 changes: 2 additions & 1 deletion backend/src/bundles/videos/video.service.ts
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,7 @@ import { type Service } from '~/common/types/types.js';
import { VideoValidationMessage } from './enums/enums.js';
import {
type CreateVideoRequestDto,
type Scene,
type UpdateVideoRequestDto,
type VideoGetAllItemResponseDto,
type VideoGetAllResponseDto,
Expand Down Expand Up @@ -61,7 +62,7 @@ class VideoService implements Service {
payload: CreateVideoRequestDto & { userId: string },
): Promise<VideoGetAllItemResponseDto> {
const previewUrl = await this.imageService.generatePreview(
payload.composition,
payload.composition.scenes[0] as Scene,
);

const video = await this.videoRepository.create(
Expand Down
8 changes: 4 additions & 4 deletions backend/src/common/services/image/image.service.ts
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ import { type FileService } from '~/common/services/file/file.service.js';

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

type Constructor = {
fileService: FileService;
Expand All @@ -20,9 +20,9 @@ class ImageService {
this.imageApi = imageApi;
}

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

if (background?.url) {
const backgroundImageBuffer = await this.imageApi.getImageBuffer(
Expand Down
2 changes: 1 addition & 1 deletion backend/src/common/services/image/types/types.ts
Original file line number Diff line number Diff line change
@@ -1 +1 @@
export { type Composition } from 'shared';
export { type Scene } from 'shared';

0 comments on commit 501b067

Please sign in to comment.