From 88f84256cf51684f97b41fb622090fe4e2d26e1f Mon Sep 17 00:00:00 2001 From: Methapon2001 <61303214+Methapon2001@users.noreply.github.com> Date: Thu, 4 Apr 2024 11:02:01 +0700 Subject: [PATCH] fix: image not on delete data --- src/controllers/branch/contact-controller.ts | 3 +++ src/controllers/user/user-controller.ts | 4 ++++ 2 files changed, 7 insertions(+) diff --git a/src/controllers/branch/contact-controller.ts b/src/controllers/branch/contact-controller.ts index 9598bb8..dde1d4f 100644 --- a/src/controllers/branch/contact-controller.ts +++ b/src/controllers/branch/contact-controller.ts @@ -161,5 +161,8 @@ export class BranchContactController extends Controller { if (result.count <= 0) { throw new HttpError(HttpStatus.NOT_FOUND, "Branch cannot be found.", "data_not_found"); } + await minio.removeObject(MINIO_BUCKET, imageLocation(contactId), { + forceDelete: true, + }); } } diff --git a/src/controllers/user/user-controller.ts b/src/controllers/user/user-controller.ts index 8674ca1..19cfc3f 100644 --- a/src/controllers/user/user-controller.ts +++ b/src/controllers/user/user-controller.ts @@ -325,6 +325,10 @@ export class UserController extends Controller { throw new HttpError(HttpStatus.FORBIDDEN, "User is in used.", "data_in_used"); } + await minio.removeObject(MINIO_BUCKET, imageLocation(userId), { + forceDelete: true, + }); + return await prisma.user.delete({ include: { province: true,