diff --git a/backend/src/bundles/templates/templates.service.ts b/backend/src/bundles/templates/templates.service.ts index a63087dbc..2c386284b 100644 --- a/backend/src/bundles/templates/templates.service.ts +++ b/backend/src/bundles/templates/templates.service.ts @@ -1,4 +1,5 @@ import { HTTPCode, HttpError } from '~/common/http/http.js'; +import { type ImageService } from '~/common/services/image/image.service.js'; import { type Service } from '~/common/types/types.js'; import { type UpdateVideoRequestDto } from '../videos/types/types.js'; @@ -14,9 +15,14 @@ import { class TemplateService implements Service { private templateRepository: TemplateRepository; + private imageService: ImageService; - public constructor(templateRepository: TemplateRepository) { + public constructor( + templateRepository: TemplateRepository, + imageService: ImageService, + ) { this.templateRepository = templateRepository; + this.imageService = imageService; } public async findById(id: string): Promise { @@ -54,7 +60,8 @@ class TemplateService implements Service { const { composition, name, userId } = payload; // TODO: CREATE PREVIEW - const compositionPreviewUrl = composition.scenes[0]?.avatar?.url ?? ''; + const compositionPreviewUrl = + await this.imageService.generatePreview(composition); const user = await this.templateRepository.create( TemplateEntity.initializeNew({ diff --git a/backend/src/bundles/templates/templates.ts b/backend/src/bundles/templates/templates.ts index 38ddbeeb4..244cb083b 100644 --- a/backend/src/bundles/templates/templates.ts +++ b/backend/src/bundles/templates/templates.ts @@ -1,4 +1,5 @@ import { logger } from '~/common/logger/logger.js'; +import { imageService } from '~/common/services/services.js'; import { TemplateController } from './templates.controller.js'; import { TemplateModel } from './templates.model.js'; @@ -6,7 +7,7 @@ import { TemplateRepository } from './templates.repository.js'; import { TemplateService } from './templates.service.js'; const templateRepository = new TemplateRepository(TemplateModel); -const templateService = new TemplateService(templateRepository); +const templateService = new TemplateService(templateRepository, imageService); const templateController = new TemplateController(logger, templateService); export { templateController };