Add group profile image upload and update support#125
Conversation
|
@bhaktiyadav08 is attempting to deploy a commit to the Akash Santra 's projects Team on Vercel. A member of the Team first needs to authorize it. |
|
Warning Review limit reached
Next review available in: 34 minutes Enable usage-based reviews in Billing to review now. Otherwise, wait until the next included review is available. How can I continue?After more reviews become available, a review can be triggered using the To avoid repeated limits, reduce automatic review volume by pausing incremental auto-reviews earlier, using label-based review opt-in, excluding WIP or generated PR titles, or requesting reviews manually when the PR is ready. If your team needs uninterrupted high-volume reviews, an organization admin can enable usage-based reviews. How do review limits work?CodeRabbit enforces per-developer PR review limits for each organization. Most developers receive the normal plan review availability. For paid Pro and Pro+ PR reviews, CodeRabbit uses adaptive limits for sustained high-volume activity. When a developer's recent PR review activity reaches the 95th percentile or higher among CodeRabbit users, additional reviews become available more gradually as earlier reviews age out of the rolling window. Please refer docs for additional details. Review details⚙️ Run configurationConfiguration used: defaults Review profile: CHILL Plan: Pro Plus Run ID: 📒 Files selected for processing (3)
📝 WalkthroughWalkthroughGroup avatars can be selected during creation, updated by admins, uploaded to Cloudinary, persisted as URLs, synchronized across group state, and displayed in the chat header, sidebar, and group information page. ChangesGroup avatar management
Estimated code review effort: 4 (Complex) | ~40 minutes Sequence Diagram(s)sequenceDiagram
participant Admin
participant GroupMembersModal
participant groupController
participant Cloudinary
participant GroupDatabase
Admin->>GroupMembersModal: select group avatar
GroupMembersModal->>groupController: PATCH avatar data
groupController->>Cloudinary: upload image
Cloudinary-->>groupController: return secure_url
groupController->>GroupDatabase: save avatar URL
GroupDatabase-->>groupController: return updated group
groupController-->>GroupMembersModal: return group data
GroupMembersModal->>GroupMembersModal: update selected group and refresh groups
Possibly related issues
🚥 Pre-merge checks | ✅ 5✅ Passed checks (5 passed)
✨ Finishing Touches🧪 Generate unit tests (beta)
Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out. Comment |
There was a problem hiding this comment.
Actionable comments posted: 3
🧹 Nitpick comments (1)
frontend/src/components/CreateGroupModal.jsx (1)
15-25: 📐 Maintainability & Code Quality | 🔵 Trivial | ⚡ Quick winInconsistent avatar validation across upload entry points. Both handlers convert the selected file to a data URL and send it without the MIME/size checks that
GroupMembersModal.jsx(L88-99) applies, so oversized or non-image files reach the backend unchecked. Extract the shared validation (file.type.startsWith("image/")+ 5 MB cap) and apply it in both.
frontend/src/components/CreateGroupModal.jsx#L15-L25: add type/size validation inhandleImageSelectbeforereadAsDataURL.frontend/src/components/ChangeGroupInfoModal.jsx#L14-L25: add the same validation inhandleImageChangebeforereadAsDataURL.🤖 Prompt for AI Agents
Verify each finding against current code. Fix only still-valid issues, skip the rest with a brief reason, keep changes minimal, and validate. In `@frontend/src/components/CreateGroupModal.jsx` around lines 15 - 25, Extract or reuse the shared avatar validation used by GroupMembersModal, requiring an image MIME type and a maximum size of 5 MB. Apply it in handleImageSelect in frontend/src/components/CreateGroupModal.jsx (lines 15-25) and handleImageChange in frontend/src/components/ChangeGroupInfoModal.jsx (lines 14-25) before each FileReader.readAsDataURL call, rejecting invalid files without updating the avatar.
🤖 Prompt for all review comments with AI agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.
Inline comments:
In `@backend/src/controllers/group.controller.js`:
- Around line 55-63: Update createGroup to validate the avatar’s MIME/type
before calling cloudinary.uploader.upload, rejecting unsupported content
server-side rather than relying on the JSON size limit. Pass folder: "groups" in
the upload options, matching updateGroup, while preserving the existing
secure_url assignment and group creation flow.
In `@frontend/src/components/CreateGroupModal.jsx`:
- Line 60: Remove the leftover console.log(res.data) debug statement from the
CreateGroupModal response handling while preserving the surrounding logic.
In `@frontend/src/components/GroupMembersModal.jsx`:
- Around line 183-184: Update the isCreatorMember comparison in
GroupMembersModal to normalize group.createdBy to its identifier when it is a
populated object, matching the normalization already used by isCreator. Preserve
support for an unpopulated string id so the creator’s remove button remains
hidden in both response shapes.
---
Nitpick comments:
In `@frontend/src/components/CreateGroupModal.jsx`:
- Around line 15-25: Extract or reuse the shared avatar validation used by
GroupMembersModal, requiring an image MIME type and a maximum size of 5 MB.
Apply it in handleImageSelect in frontend/src/components/CreateGroupModal.jsx
(lines 15-25) and handleImageChange in
frontend/src/components/ChangeGroupInfoModal.jsx (lines 14-25) before each
FileReader.readAsDataURL call, rejecting invalid files without updating the
avatar.
🪄 Autofix (Beta)
Fix all unresolved CodeRabbit comments on this PR:
- Push a commit to this branch (recommended)
- Create a new PR with the fixes
ℹ️ Review info
⚙️ Run configuration
Configuration used: defaults
Review profile: CHILL
Plan: Pro Plus
Run ID: c000b8c4-daba-4587-b448-66114736d6ca
📒 Files selected for processing (8)
.gitignorebackend/src/controllers/group.controller.jsfrontend/src/components/ChangeGroupInfoModal.jsxfrontend/src/components/ChatHeader.jsxfrontend/src/components/CreateGroupModal.jsxfrontend/src/components/GroupMembersModal.jsxfrontend/src/components/Sidebar.jsxfrontend/src/pages/GroupInfoPage.jsx
Summary
Implemented full group profile image support.
Backend
Frontend
Testing
Summary by CodeRabbit
Summary by CodeRabbit
New Features
Improvements
Chores