Skip to content

feat(messages): add message forwarding supportFeat/add message forwarding support#131

Open
nihar-ux18 wants to merge 10 commits into
CodePlaygroundHub:mainfrom
nihar-ux18:feat/add-message-forwarding-support
Open

feat(messages): add message forwarding supportFeat/add message forwarding support#131
nihar-ux18 wants to merge 10 commits into
CodePlaygroundHub:mainfrom
nihar-ux18:feat/add-message-forwarding-support

Conversation

@nihar-ux18

@nihar-ux18 nihar-ux18 commented Jul 24, 2026

Copy link
Copy Markdown
Contributor

Summary

This PR adds support for forwarding messages across private and group conversations.

Changes

  • Added forwarding metadata to the Message model
    • isForwarded
    • originalMessageId
  • Implemented backend message forwarding API
  • Added Socket.IO support for real-time forwarded messages
  • Added "Forward" option to the message action menu
  • Added conversation selection for forwarding messages
  • Displayed a "Forwarded" indicator on forwarded messages

Supported Forwarding

  • ✅ Text messages
  • ✅ Images
  • ✅ Audio
  • ✅ Documents
  • ✅ Private chats
  • ✅ Group chats
  • ✅ Multiple destination conversations

Testing

  • Forwarded text messages
  • Forwarded media messages
  • Verified real-time synchronization via Socket.IO
  • Verified existing messaging functionality remains unaffected

And I have attached a screen recording of working of the forward feature.

Screen.Recording.2026-07-24.at.12.03.22.mov

Summary by CodeRabbit

  • New Features
    • Added the ability to forward messages to multiple users and groups.
    • Introduced a recipient picker modal with selection validation, loading state, and success/error notifications.
    • Forwarded messages now show a “Forwarded” badge.
    • Forwarding preserves the original message content (including text and attachments) while enforcing access permissions.
  • Configuration
    • Updated formatting in the example environment file’s Redis URL section (no functional change).

@vercel

vercel Bot commented Jul 24, 2026

Copy link
Copy Markdown

@nihar-ux18 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.

@coderabbitai

coderabbitai Bot commented Jul 24, 2026

Copy link
Copy Markdown

Review Change Stack

Warning

Review limit reached

@nihar-ux18, you've reached your PR review limit, so we couldn't start this review.

Next review available in: 52 minutes

Enable usage-based reviews in Billing to review now. Otherwise, wait until the next included review is available.
You're only billed for reviews past your plan's rate limits ($0.25/file).

How can I continue?

After more reviews become available, a review can be triggered using the @coderabbitai review command as a PR comment. Alternatively, push new commits to this PR.

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 configuration

Configuration used: defaults

Review profile: CHILL

Plan: Pro Plus

Run ID: b5b1cbdc-6fe5-42b2-850b-297f034b5697

📥 Commits

Reviewing files that changed from the base of the PR and between 6ae0b59 and 9d6093d.

📒 Files selected for processing (1)
  • backend/src/controllers/message.controller.js
📝 Walkthrough

Walkthrough

Message forwarding adds persisted lineage fields, a protected backend endpoint with user/group delivery events, and frontend recipient selection with forwarded-message indicators.

Changes

Message forwarding

Layer / File(s) Summary
Forwarding endpoint and message lineage
backend/src/models/message.model.js, backend/src/routes/message.route.js, backend/src/controllers/message.controller.js, backend/.env.example
Messages gain forwarding metadata; the protected endpoint validates access, creates forwarded copies for users or groups, and emits corresponding socket events.
Recipient selection and submission
frontend/src/components/ForwardModal.jsx
The modal selects users or groups, validates destinations, submits the forwarding request, and reports request status.
Message action and forwarded state display
frontend/src/components/MessageBubble.jsx
The message menu opens the forwarding modal, passes available recipients, retains outside-click behavior, and displays a Forwarded badge.

Estimated code review effort: 3 (Moderate) | ~25 minutes

Sequence Diagram(s)

sequenceDiagram
  participant User
  participant MessageBubble
  participant ForwardModal
  participant forwardMessage
  participant Message
  participant SocketIO
  User->>MessageBubble: Select Forward
  MessageBubble->>ForwardModal: Open with messageId and recipients
  User->>ForwardModal: Select users or groups
  ForwardModal->>forwardMessage: POST /messages/forward
  forwardMessage->>Message: Load original and create forwarded copies
  forwardMessage->>SocketIO: Emit recipient delivery events
  forwardMessage-->>ForwardModal: Return created messages
  ForwardModal-->>User: Show success or error toast
Loading

Possibly related issues

  • CodePlaygroundHub/paso-chat-app#116 — Covers multi-recipient message forwarding, media preservation, forwarded indicators, permissions, and real-time delivery.

Suggested labels: enhancement

Suggested reviewers: akash504-ai

🚥 Pre-merge checks | ✅ 5
✅ Passed checks (5 passed)
Check name Status Explanation
Description Check ✅ Passed Check skipped - CodeRabbit’s high-level summary is enabled.
Title check ✅ Passed The title matches the main change: adding message forwarding support.
Docstring Coverage ✅ Passed No functions found in the changed files to evaluate docstring coverage. Skipping docstring coverage check.
Linked Issues check ✅ Passed Check skipped because no linked issues were found for this pull request.
Out of Scope Changes check ✅ Passed Check skipped because no linked issues were found for this pull request.
✨ Finishing Touches
🧪 Generate unit tests (beta)
  • Create PR with unit tests

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.

❤️ Share

Comment @coderabbitai help to get the list of available commands.

@coderabbitai coderabbitai Bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Actionable comments posted: 4

🤖 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/.env.example`:
- Line 2: Replace the live MongoDB connection string in the environment example
with a generic placeholder containing no real username, password, or host
credentials, and rotate or revoke the exposed Atlas database secret through the
appropriate secret-management path.

In `@backend/src/controllers/message.controller.js`:
- Around line 367-418: Update the forwarding flow around originalMessage and the
destinations loop to authorize the requester before processing content: require
senderId to be the original sender or receiver, or a member of
originalMessage.groupId, and reject unauthorized access without exposing the
message. For each groupId destination, verify senderId membership using the same
isMember guard or established group-membership mechanism as sendGroupMessage
before Message.create or socket emission; preserve valid user-destination
forwarding.
- Around line 363-378: Validate messageId and destinations at the start of the
forwarding handler, before calling Message.findById or iterating destinations.
Require a valid messageId format and require destinations to be an array; return
a 400 response for either invalid input, following the validation pattern used
by sendMessage and sendGroupMessage. Preserve the existing forwarding flow for
valid requests.

In `@frontend/src/components/MessageBubble.jsx`:
- Around line 301-323: Remove the `${message.isForwarded && (...)}` JSX block
from the bubble `className` template in `MessageBubble`, leaving only valid
class-string interpolations. Remove the stray `ƒ` prefix from the non-sender
background class, and retain the existing Forwarded badge rendering around the
later badge block.
🪄 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: 547c1412-61c0-4903-85e9-e655e469eee2

📥 Commits

Reviewing files that changed from the base of the PR and between 64c82d1 and c584880.

📒 Files selected for processing (6)
  • backend/.env.example
  • backend/src/controllers/message.controller.js
  • backend/src/models/message.model.js
  • backend/src/routes/message.route.js
  • frontend/src/components/ForwardModal.jsx
  • frontend/src/components/MessageBubble.jsx

Comment thread backend/.env.example Outdated
Comment thread backend/src/controllers/message.controller.js
Comment thread backend/src/controllers/message.controller.js
Comment thread frontend/src/components/MessageBubble.jsx Outdated

@coderabbitai coderabbitai Bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Actionable comments posted: 1

🤖 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/message.controller.js`:
- Around line 391-395: Update both group-membership checks in sendGroupMessage
at backend/src/controllers/message.controller.js lines 391-395 and 416-420 to
compare member.userId.toString() with senderId.toString(), ensuring
authorization works for embedded member documents.
🪄 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: 93d78b73-cf2d-4524-a04a-2943d67c0b65

📥 Commits

Reviewing files that changed from the base of the PR and between c584880 and 6ae0b59.

📒 Files selected for processing (3)
  • backend/.env.example
  • backend/src/controllers/message.controller.js
  • frontend/src/components/MessageBubble.jsx
🚧 Files skipped from review as they are similar to previous changes (1)
  • frontend/src/components/MessageBubble.jsx

Comment thread backend/src/controllers/message.controller.js
@nihar-ux18

Copy link
Copy Markdown
Contributor Author

Hi @Akash504-ai, I've completed the implementation for #116 (Add Message Forwarding Support) and addressed the review feedback. Could you please take a look and let me know if any further changes are needed? Thanks!

@Akash504-ai

Copy link
Copy Markdown
Member

Thanks! I'll take a look when I get some time and let you know if there's any feedback. Appreciate it.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants