sending the presigned url in getAMDetailById

This commit is contained in:
2025-11-29 16:24:15 +05:30
parent 5ad17869be
commit b1a70acfa8
3 changed files with 29 additions and 4 deletions

View File

@@ -1322,7 +1322,7 @@ export class MinglarService {
}
async getAMdetailById(id: number) {
return this.prisma.user.findUnique({
const user = await this.prisma.user.findUnique({
where: { id: id, isActive: true, userStatus: USER_STATUS.ACTIVE },
include: {
userAddressDetails: {
@@ -1352,6 +1352,31 @@ export class MinglarService {
},
},
});
const bucket = config.aws.bucketName;
if (user.userDocuments?.length) {
for (const media of user.userDocuments) {
if (!media.fileName) continue;
// Extract S3 key if URL or keep raw key
const key = media.fileName.startsWith("http")
? media.fileName.split(".com/")[1]
: media.fileName;
media.fileName = await getPresignedUrl(bucket, key);
}
}
if (user.profileImage) {
const key = user.profileImage.startsWith('http')
? user.profileImage.split('.com/')[1]
: user.profileImage;
user.profileImage = await getPresignedUrl(bucket, key);
}
return user;
}
async getBasicUserDetails(user_xid) {