diff --git a/server/src/contexts/profile/application/UploadProfileLogo.useCase.ts b/server/src/contexts/profile/application/UploadProfileLogo.useCase.ts index db2c3ce..4c86e59 100644 --- a/server/src/contexts/profile/application/UploadProfileLogo.useCase.ts +++ b/server/src/contexts/profile/application/UploadProfileLogo.useCase.ts @@ -63,8 +63,8 @@ export class UploadProfileLogoUseCase return this._saveProfile(profile); } - private async _deleteOldLogo(filename) { - const logo_path = `${this._defaults.dealer_logos_upload_path}/${filename}`; + private async _deleteOldLogo(logo: ProfileLogotype) { + const logo_path = logo.relativePath(); await fs.rm(logo_path); } @@ -88,14 +88,14 @@ export class UploadProfileLogoUseCase private async _getProfileDealer(userId: UniqueID) { const transaction = this._adapter.startTransaction(); - const dealerRepoBuilder = this._getProfileRepository(); + const profileRepoBuilder = this._getProfileRepository(); let profile: Profile | null = null; try { await transaction.complete(async (t) => { - const dealerRepo = dealerRepoBuilder({ transaction: t }); - profile = await dealerRepo.getByUserId(userId); + const profileRepo = profileRepoBuilder({ transaction: t }); + profile = await profileRepo.getByUserId(userId); }); if (!profile) { diff --git a/server/src/contexts/profile/domain/entities/ProfileLogotype.ts b/server/src/contexts/profile/domain/entities/ProfileLogotype.ts index a48af62..8094350 100644 --- a/server/src/contexts/profile/domain/entities/ProfileLogotype.ts +++ b/server/src/contexts/profile/domain/entities/ProfileLogotype.ts @@ -2,7 +2,6 @@ import { config } from "@/config"; import { IValueObjectOptions, Result, ValueObject } from "@shared/contexts"; import fs from "fs/promises"; import mime from "mime-types"; -import path from "path"; export interface IProfileLogotypeOptions extends IValueObjectOptions {} @@ -38,12 +37,8 @@ export class ProfileLogotype extends ValueObject { } public relativePath() { - // `${context.defaults.dealer_logos_upload_path}/${profile.logo}` return this.filename - ? path.format({ - base: config.defaults.dealer_logos_upload_path, - name: this.filename, - }) + ? `${config.defaults.dealer_logos_upload_path}/${this.filename}` : config.defaults.dealer_logo_placeholder; }