From d16374ad0e76d800ad74a759562f229b9c8f2738 Mon Sep 17 00:00:00 2001 From: Brok3Turtl3 Date: Wed, 3 Apr 2024 11:23:13 -0400 Subject: [PATCH 1/2] CHE-53 Adjusted profile thumbs to display images if present and updated getAllProfiles controller to obtain presigned URLS for S3 --- .../src/components/ProfileThumb/ProfileThumb.tsx | 9 ++++++++- server/controllers/profileController.ts | 16 +++++++++++++++- 2 files changed, 23 insertions(+), 2 deletions(-) diff --git a/client/src/components/ProfileThumb/ProfileThumb.tsx b/client/src/components/ProfileThumb/ProfileThumb.tsx index 764514b..6ea3856 100644 --- a/client/src/components/ProfileThumb/ProfileThumb.tsx +++ b/client/src/components/ProfileThumb/ProfileThumb.tsx @@ -10,7 +10,14 @@ const ProfileThumb = ({ profile }: ProfileThumbProps): JSX.Element => { const dispatch = useAppDispatch(); return ( -
+
+ {profile.profilePhoto && ( + Profile + )}

{profile.fullName}

{profile.personalBio}

diff --git a/server/controllers/profileController.ts b/server/controllers/profileController.ts index eacc6af..1d284d0 100644 --- a/server/controllers/profileController.ts +++ b/server/controllers/profileController.ts @@ -147,7 +147,21 @@ const getAllProfiles = async ( message: { err: "There were no profiles to retrieve" }, }); } else { - return res.status(201).json(profiles); + const processedProfiles = await Promise.all( + profiles.map(async (profile) => { + if (profile.profilePhoto) { + const presignedUrl = s3.getSignedUrl("getObject", { + Bucket: process.env.BUCKET_NAME, + Key: profile.profilePhoto, + Expires: 60 * 5, + }); + profile.profilePhoto = presignedUrl; + } + return profile.toObject(); + }) + ); + + return res.status(201).json(processedProfiles); } } catch (error) { return next({ From ca1e375c269b6f827923a6820c34e3122ec00070 Mon Sep 17 00:00:00 2001 From: Brok3Turtl3 Date: Wed, 3 Apr 2024 11:33:15 -0400 Subject: [PATCH 2/2] CHE-53 Updated snapshot for tests --- .../src/pages/Profiles/__snapshots__/Profiles.test.tsx.snap | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/client/src/pages/Profiles/__snapshots__/Profiles.test.tsx.snap b/client/src/pages/Profiles/__snapshots__/Profiles.test.tsx.snap index 08d4388..5be788e 100644 --- a/client/src/pages/Profiles/__snapshots__/Profiles.test.tsx.snap +++ b/client/src/pages/Profiles/__snapshots__/Profiles.test.tsx.snap @@ -17,7 +17,7 @@ exports[`MainPage Component renders correctly 1`] = ` onClick={[Function]} >