Merge branch 'sprint1' of http://git.wdipl.com/Mayank.Mishra/MinglarBackendNestJS into paritosh-main1
This commit is contained in:
@@ -102,6 +102,17 @@ export class HostService {
|
||||
documentType: true,
|
||||
},
|
||||
},
|
||||
accountManager: {
|
||||
select: {
|
||||
id: true,
|
||||
firstName: true,
|
||||
lastName: true,
|
||||
emailAddress: true,
|
||||
mobileNumber: true,
|
||||
profileImage: true,
|
||||
userRefNumber: true,
|
||||
}
|
||||
},
|
||||
user: {
|
||||
select: {
|
||||
id: true,
|
||||
@@ -161,7 +172,7 @@ export class HostService {
|
||||
}
|
||||
}
|
||||
}
|
||||
if (host.user.profileImage) {
|
||||
if (host.user?.profileImage) {
|
||||
const key = host.user.profileImage.startsWith("http")
|
||||
? host.user.profileImage.split(".com/")[1]
|
||||
: host.user.profileImage;
|
||||
@@ -169,7 +180,7 @@ export class HostService {
|
||||
host.user.profileImage = await getPresignedUrl(bucket, key);
|
||||
}
|
||||
|
||||
if (host.logoPath) {
|
||||
if (host?.logoPath) {
|
||||
const key = host.logoPath.startsWith('http')
|
||||
? host.logoPath.split('.com/')[1]
|
||||
: host.logoPath;
|
||||
@@ -177,6 +188,14 @@ export class HostService {
|
||||
host.logoPath = await getPresignedUrl(bucket, key);
|
||||
}
|
||||
|
||||
if (host.accountManager?.profileImage) {
|
||||
const key = host.accountManager.profileImage.startsWith('http')
|
||||
? host.accountManager.profileImage.split('.com/')[1]
|
||||
: host.accountManager.profileImage;
|
||||
|
||||
host.accountManager.profileImage = await getPresignedUrl(bucket, key);
|
||||
}
|
||||
|
||||
if (host.hostParent?.length) {
|
||||
const parent = host.hostParent[0]; // since you allow only 1 parent
|
||||
|
||||
@@ -365,18 +384,76 @@ export class HostService {
|
||||
});
|
||||
}
|
||||
|
||||
async getAllHostActivity(search?: string, hostXid?: number) {
|
||||
return await this.prisma.activities.findMany({
|
||||
async getAllHostActivity(search?: string, user_xid?: number) {
|
||||
const hostDetails = await this.prisma.hostHeader.findFirst({
|
||||
where: { userXid: user_xid, isActive: true }
|
||||
})
|
||||
|
||||
const hostAllActivities = await this.prisma.activities.findMany({
|
||||
where: {
|
||||
isActive: true,
|
||||
hostXid: hostXid,
|
||||
hostXid: hostDetails.id,
|
||||
},
|
||||
include: {
|
||||
ActivitiesMedia: true,
|
||||
ActivityAmDetails: true,
|
||||
ActivityAmDetails: {
|
||||
select: {
|
||||
accountManager: {
|
||||
select: {
|
||||
id: true,
|
||||
firstName: true,
|
||||
lastName: true,
|
||||
profileImage: true,
|
||||
emailAddress: true,
|
||||
roleXid: true,
|
||||
},
|
||||
},
|
||||
},
|
||||
},
|
||||
activityType: true,
|
||||
},
|
||||
});
|
||||
|
||||
for (const activity of hostAllActivities) {
|
||||
|
||||
/** 1️⃣ Process Activity Media */
|
||||
const processedMedia = [];
|
||||
|
||||
for (const media of activity.ActivitiesMedia || []) {
|
||||
|
||||
const key = media.mediaFileName?.startsWith("http")
|
||||
? media.mediaFileName.split(".com/")[1]
|
||||
: media.mediaFileName;
|
||||
|
||||
const presignedUrl = key ? await getPresignedUrl(bucket, key) : null;
|
||||
|
||||
processedMedia.push({
|
||||
...media,
|
||||
presignedUrl,
|
||||
});
|
||||
}
|
||||
|
||||
activity.ActivitiesMedia = processedMedia;
|
||||
|
||||
/** 2️⃣ Process AM Profile Image */
|
||||
const am = activity.ActivityAmDetails?.[0]?.accountManager;
|
||||
|
||||
if (am?.profileImage) {
|
||||
const key = am.profileImage.startsWith("http")
|
||||
? am.profileImage.split(".com/")[1]
|
||||
: am.profileImage;
|
||||
|
||||
const presignedUrl = await getPresignedUrl(bucket, key);
|
||||
|
||||
activity.ActivityAmDetails[0].accountManager = {
|
||||
...am,
|
||||
profileImage: presignedUrl,
|
||||
};
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
return hostAllActivities;
|
||||
}
|
||||
|
||||
async acceptMinglarAgreement(user_xid: number) {
|
||||
|
||||
Reference in New Issue
Block a user