Skip to content

feat: Contact name and avatar resolution for external voice calls#40484

Open
aleksandernsilva wants to merge 3 commits into
developfrom
feat/voice-identity-lookup
Open

feat: Contact name and avatar resolution for external voice calls#40484
aleksandernsilva wants to merge 3 commits into
developfrom
feat/voice-identity-lookup

Conversation

@aleksandernsilva
Copy link
Copy Markdown
Contributor

@aleksandernsilva aleksandernsilva commented May 11, 2026

Proposed changes (including videos or screenshots)

This PR improves how external voice call participants are displayed across media calls and call history.

What changed

  • Added contactName and contactUsername to external call history items.
  • Updated MediaCallService to resolve and persist external contact information when logging calls.
  • Improved SIP invite parsing in IncomingSipCall to better extract caller names from SIP headers, prioritizing Rocket.Chat-specific headers before falling back to standard SIP fields.

Frontend updates

  • Updated CallHistoryExternalUser, PeerInfo, and related components to display external contact names and avatars when available.
  • Added proper fallbacks for cases where only the phone number is available.
  • Extended component props, Storybook stories, and snapshots to cover external users with names and avatars.

API and typings

  • Updated API responses and typings to support the new external contact fields end-to-end.
    Tests
  • Refactored and expanded tests to validate the new fields and their usage across the UI and autocomplete flows.

Overall, these changes make external participants feel more consistent with internal users throughout the calling experience.

Issue(s)

DMV-2
DMV-3

Steps to test or reproduce

Further comments

Summary by CodeRabbit

Release Notes

New Features

  • External call history contacts now display caller names and usernames alongside phone numbers
  • External call contacts can now display avatars when caller information is available, providing improved visual identification in call records

Refactor

  • Updated call history contact display components to support enhanced external contact information

Review Change Stack

@dionisio-bot
Copy link
Copy Markdown
Contributor

dionisio-bot Bot commented May 11, 2026

Looks like this PR is not ready to merge, because of the following issues:

  • This PR is missing the 'stat: QA assured' label

Please fix the issues and try again

If you have any trouble, please check the PR guidelines

@changeset-bot
Copy link
Copy Markdown

changeset-bot Bot commented May 11, 2026

🦋 Changeset detected

Latest commit: 54a6296

The changes in this PR will be included in the next version bump.

This PR includes changesets to release 19 packages
Name Type
@rocket.chat/media-calls Minor
@rocket.chat/model-typings Minor
@rocket.chat/ui-voip Major
@rocket.chat/models Minor
@rocket.chat/i18n Minor
@rocket.chat/core-typings Minor
@rocket.chat/rest-typings Minor
@rocket.chat/meteor Minor
@rocket.chat/ui-client Major
@rocket.chat/mock-providers Patch
@rocket.chat/ui-contexts Major
@rocket.chat/web-ui-registration Major
@rocket.chat/uikit-playground Patch
@rocket.chat/fuselage-ui-kit Major
@rocket.chat/gazzodown Major
@rocket.chat/livechat Patch
@rocket.chat/ui-avatar Major
@rocket.chat/ui-video-conf Major
@rocket.chat/ui-composer Major

Not sure what this means? Click here to learn what changesets are.

Click here if you're a maintainer who wants to add another changeset to this PR

@coderabbitai
Copy link
Copy Markdown
Contributor

coderabbitai Bot commented May 11, 2026

Note

Reviews paused

It looks like this branch is under active development. To avoid overwhelming you with review comments due to an influx of new commits, CodeRabbit has automatically paused this review. You can configure this behavior by changing the reviews.auto_review.auto_pause_after_reviewed_commits setting.

Use the following commands to manage reviews:

  • @coderabbitai resume to resume automatic reviews.
  • @coderabbitai review to trigger a single review.

Use the checkboxes below for quick actions:

  • ▶️ Resume reviews
  • 🔍 Trigger review

Walkthrough

PR enriches external voice call history with contact metadata (name, username) via improved SIP header parsing, introduces a configurable SIP identity lookup mechanism, and refactors peer information types throughout the VoIP UI layer to use an explicit external boolean discriminant for distinguishing phone-based versus user-based peers.

Changes

SIP Identity & External Call History Enrichment

Layer / File(s) Summary
SIP Header Parsing & Server Configuration
ee/packages/media-calls/src/sip/providers/IncomingSipCall.ts, apps/meteor/server/services/media-call/service.ts
New getDisplayNameFromInvite helper extracts normalized caller display name from prioritized SIP headers; getCallerContactFromInvite refactored to use the helper and resolve username only from explicit headers. Server settings extended with sip.identityLookup configuration section.
Call History Data Model & Storage
packages/core-typings/src/ICallHistoryItem.ts, apps/meteor/server/services/media-call/service.ts, apps/meteor/app/api/server/v1/call-history.ts
IExternalMediaCallHistoryItem types contactName and contactUsername as plain optional strings. Service derives contactName from contact display info and stores both fields in call history. API layer filters call history by regex on contact name/username fields.
PeerInfo Type System
packages/ui-voip/src/context/definitions.d.ts, packages/ui-voip/src/components/PeerInfo/*, packages/ui-voip/src/components/CallHistoryExternalUser.tsx
InternalPeerInfo and ExternalPeerInfo add external: false/true discriminant; ExternalPeerInfo makes display and avatar optional. New ExternalUser component and ExternalUserProps introduced. PeerInfoProps refactored to discriminated union. InternalUserProps exported for component reuse.
PeerInfo Derivation & Utilities
packages/ui-voip/src/utils/derivePeerInfoFromInstanceContact.ts, packages/ui-voip/src/utils/derivePeerInfoFromInstanceState.ts, packages/ui-voip/src/providers/useMediaSession.ts
Utility functions add external: true/false flag to derived peer info. Avatar URL computation refactored to derive from username or user ID and thread into peer info payloads for both SIP and generic contacts.
Autocomplete & Provider Integration
packages/ui-voip/src/context/usePeerAutocomplete.ts, packages/ui-voip/src/providers/MockedMediaCallProvider.tsx
usePeerAutocomplete passes external: true for synthetic first option and external: false for peer matches. MockedMediaCallProvider includes external: false in initial and resolved peer info to maintain consistent shape.
Rendering & Component Logic
packages/ui-voip/src/views/MediaCallWidget/OngoingCall.tsx, packages/ui-voip/src/views/MediaCallWidget/OngoingCallWithScreen.tsx, packages/ui-voip/src/hooks/useMediaCallAction.ts
OngoingCall branches PeerInfo rendering on external, adding slots and remoteMuted only for internal peers. Hangup button label logic uses external flag to select display text. useMediaCallAction simplifies label derivation.
Call History UI Components
packages/ui-voip/src/components/CallHistoryExternalUser.tsx, apps/meteor/client/views/mediaCallHistory/*, packages/ui-voip/src/views/CallHistoryContextualbar/CallHistoryContextualbar.tsx, packages/ui-voip/src/views/MediaCallHistoryTable/*
CallHistoryExternalUser accepts optional name and username, derives avatar URL from username, renders avatar or icon fallback. Call history pages, tables, and contextual panels map and pass enriched contact fields to display components. Type contracts updated to include optional name/username.
Tests & Release Notes
packages/ui-voip/src/context/usePeekMediaSessionPeerInfo.spec.tsx, packages/ui-voip/src/context/usePeerAutocomplete.spec.tsx, packages/ui-voip/src/hooks/useMediaCallAction.spec.tsx, packages/ui-voip/src/utils/derivePeerInfoFromInstanceContact.spec.ts, packages/ui-voip/src/utils/derivePeerInfoFromInstanceState.spec.ts, packages/ui-voip/src/components/PeerInfo/PeerInfo.stories.tsx, packages/ui-voip/src/views/MediaCallHistoryTable/MediaCallHistoryTable.stories.tsx, .changeset/fuzzy-terms-brake.md
Test fixtures updated across all peer-info consumers to validate external discriminant for both SIP and user contacts. Storybook mock data includes external field. Release notes document name and avatar resolution for external voice calls.

Estimated code review effort

🎯 4 (Complex) | ⏱️ ~50 minutes

Suggested reviewers

  • tassoevan
🚥 Pre-merge checks | ✅ 4 | ❌ 1

❌ Failed checks (1 warning)

Check name Status Explanation Resolution
Docstring Coverage ⚠️ Warning Docstring coverage is 0.00% which is insufficient. The required threshold is 80.00%. Write docstrings for the functions missing them to satisfy the coverage threshold.
✅ Passed checks (4 passed)
Check name Status Explanation
Title check ✅ Passed The title accurately and concisely summarizes the main objective of the changeset: adding contact name and avatar resolution for external voice calls. It directly reflects the primary feature across all modified files.
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.
Description Check ✅ Passed Check skipped - CodeRabbit’s high-level summary is enabled.

✏️ Tip: You can configure your own custom pre-merge checks in the settings.

Warning

Review ran into problems

🔥 Problems

Errors were encountered while retrieving linked issues.

Errors (2)
  • DMV-2: Request failed with status code 401
  • DMV-3: Request failed with status code 401

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 and usage tips.

@aleksandernsilva aleksandernsilva force-pushed the feat/voice-identity-lookup branch 2 times, most recently from fc5e7a7 to cc1ce77 Compare May 11, 2026 22:38
@codecov
Copy link
Copy Markdown

codecov Bot commented May 11, 2026

Codecov Report

❌ Patch coverage is 79.62963% with 11 lines in your changes missing coverage. Please review.
✅ Project coverage is 69.66%. Comparing base (af676c5) to head (54a6296).
⚠️ Report is 1 commits behind head on develop.

Additional details and impacted files

Impacted file tree graph

@@             Coverage Diff             @@
##           develop   #40484      +/-   ##
===========================================
+ Coverage    69.65%   69.66%   +0.01%     
===========================================
  Files         3339     3340       +1     
  Lines       123269   123326      +57     
  Branches     21982    21978       -4     
===========================================
+ Hits         85864    85921      +57     
- Misses       34033    34054      +21     
+ Partials      3372     3351      -21     
Flag Coverage Δ
e2e 59.22% <ø> (+0.08%) ⬆️
e2e-api 46.04% <0.00%> (-0.78%) ⬇️
unit 70.47% <81.13%> (+<0.01%) ⬆️

Flags with carried forward coverage won't be shown. Click here to find out more.

🚀 New features to boost your workflow:
  • ❄️ Test Analytics: Detect flaky tests, report on failures, and find test suite problems.
  • 📦 JS Bundle Analysis: Save yourself from yourself by tracking and limiting bundle sizes in JS merges.

@aleksandernsilva aleksandernsilva force-pushed the feat/voice-identity-lookup branch from cc1ce77 to 060cfd3 Compare May 12, 2026 13:49
@aleksandernsilva
Copy link
Copy Markdown
Contributor Author

@coderabbitai review

@coderabbitai
Copy link
Copy Markdown
Contributor

coderabbitai Bot commented May 12, 2026

✅ Actions performed

Review triggered.

Note: CodeRabbit is an incremental review system and does not re-review already reviewed commits. This command is applicable only when automatic reviews are paused.

@coderabbitai coderabbitai Bot added the type: feature Pull requests that introduces new feature label May 12, 2026
Copy link
Copy Markdown
Contributor

@coderabbitai coderabbitai Bot left a comment

Choose a reason for hiding this comment

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

Caution

Some comments are outside the diff and can’t be posted inline due to platform limitations.

⚠️ Outside diff range comments (1)
ee/packages/media-calls/src/server/CastDirector.ts (1)

95-97: ⚠️ Potential issue | 🟠 Major | ⚡ Quick win

Preserve SIP contact when user is resolved via custom field.

At Line 95, a custom-field match without freeSwitchExtension builds a list with sip: null, so requiredType: 'sip' can incorrectly return null for a valid SIP identifier.

🔧 Proposed fix
-		const list = user
-			? this.buildContactListForUser(user, defaultContactInfo)
+		const list = user
+			? this.buildContactListForUser({ ...user, freeSwitchExtension: user.freeSwitchExtension ?? sipExtension }, defaultContactInfo)
 			: this.buildContactListForExtension(sipExtension, defaultContactInfo);
🤖 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 `@ee/packages/media-calls/src/server/CastDirector.ts` around lines 95 - 97, The
contact list creation can end up with sip: null when a user is matched via a
custom field but lacks freeSwitchExtension; update the logic so
buildContactListForUser (or the place that constructs the contact object after
resolving user) preserves or falls back to the provided sipExtension (the
sipExtension parameter passed into the ternary) when the resolved user's
freeSwitchExtension/contact.sip is missing — i.e., if contact.sip is falsy,
assign sipExtension before returning the list so requiredType: 'sip' will return
a valid SIP identifier; ensure similar fallback is not needed in
buildContactListForExtension which already consumes sipExtension.
🧹 Nitpick comments (1)
packages/models/src/models/Users.ts (1)

2768-2775: ⚡ Quick win

Consider adding active user filter for identity lookup use case.

The new findOneByCustomFieldValue method doesn't filter by active: true. Based on the PR context (SIP identity lookup for external calls), you likely want to match only active users. Other similar lookup methods like findOneByFreeSwitchExtension also don't filter by active status, but for identity resolution in active call scenarios, filtering inactive users would be safer.

💡 Suggested refinement
 findOneByCustomFieldValue<T extends Document = IUser>(fieldName: string, value: unknown, options: FindOptions<IUser> = {}) {
   return this.findOne<T>(
     {
+      active: true,
       [`customFields.${fieldName}`]: value,
     } as Filter<IUser>,
     options,
   );
 }
🤖 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 `@packages/models/src/models/Users.ts` around lines 2768 - 2775, The
findOneByCustomFieldValue method currently queries only on customFields and
should also restrict to active users for identity lookup; update the query
inside findOneByCustomFieldValue (and consider same for
findOneByFreeSwitchExtension if relevant) to include active: true (e.g., merge
`{ active: true }` with the existing filter or use an $and array) so the
returned IUser is guaranteed active while preserving the provided options and
types (keep the existing T extends Document and Filter<IUser> usage).
🤖 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.

Outside diff comments:
In `@ee/packages/media-calls/src/server/CastDirector.ts`:
- Around line 95-97: The contact list creation can end up with sip: null when a
user is matched via a custom field but lacks freeSwitchExtension; update the
logic so buildContactListForUser (or the place that constructs the contact
object after resolving user) preserves or falls back to the provided
sipExtension (the sipExtension parameter passed into the ternary) when the
resolved user's freeSwitchExtension/contact.sip is missing — i.e., if
contact.sip is falsy, assign sipExtension before returning the list so
requiredType: 'sip' will return a valid SIP identifier; ensure similar fallback
is not needed in buildContactListForExtension which already consumes
sipExtension.

---

Nitpick comments:
In `@packages/models/src/models/Users.ts`:
- Around line 2768-2775: The findOneByCustomFieldValue method currently queries
only on customFields and should also restrict to active users for identity
lookup; update the query inside findOneByCustomFieldValue (and consider same for
findOneByFreeSwitchExtension if relevant) to include active: true (e.g., merge
`{ active: true }` with the existing filter or use an $and array) so the
returned IUser is guaranteed active while preserving the provided options and
types (keep the existing T extends Document and Filter<IUser> usage).

ℹ️ Review info
⚙️ Run configuration

Configuration used: Organization UI

Review profile: CHILL

Plan: Pro

Run ID: ec461bdb-af54-4ba3-b521-d62645a003ec

📥 Commits

Reviewing files that changed from the base of the PR and between 6b2afb3 and 060cfd3.

⛔ Files ignored due to path filters (3)
  • packages/ui-voip/src/components/PeerInfo/__snapshots__/PeerInfo.spec.tsx.snap is excluded by !**/*.snap
  • packages/ui-voip/src/views/CallHistoryContextualbar/__snapshots__/CallHistoryContextualbar.spec.tsx.snap is excluded by !**/*.snap
  • packages/ui-voip/src/views/MediaCallHistoryTable/__snapshots__/MediaCallHistoryTable.spec.tsx.snap is excluded by !**/*.snap
📒 Files selected for processing (41)
  • apps/meteor/app/api/server/v1/call-history.ts
  • apps/meteor/client/views/mediaCallHistory/CallHistoryPage.tsx
  • apps/meteor/client/views/mediaCallHistory/MediaCallHistoryExternal.tsx
  • apps/meteor/ee/server/settings/voip.ts
  • apps/meteor/server/services/media-call/service.ts
  • apps/meteor/server/startup/migrations/index.ts
  • apps/meteor/server/startup/migrations/v336.ts
  • ee/packages/media-calls/src/definition/IMediaCallCastDirector.ts
  • ee/packages/media-calls/src/definition/IMediaCallServer.ts
  • ee/packages/media-calls/src/server/CastDirector.ts
  • ee/packages/media-calls/src/server/MediaCallServer.ts
  • ee/packages/media-calls/src/server/getDefaultSettings.ts
  • ee/packages/media-calls/src/sip/providers/IncomingSipCall.ts
  • packages/core-typings/src/ICallHistoryItem.ts
  • packages/i18n/src/locales/en.i18n.json
  • packages/i18n/src/locales/pt-BR.i18n.json
  • packages/model-typings/src/models/IUsersModel.ts
  • packages/models/src/models/Users.ts
  • packages/ui-voip/src/components/CallHistoryExternalUser.tsx
  • packages/ui-voip/src/components/PeerInfo/ExternalUser.tsx
  • packages/ui-voip/src/components/PeerInfo/InternalUser.tsx
  • packages/ui-voip/src/components/PeerInfo/PeerInfo.stories.tsx
  • packages/ui-voip/src/components/PeerInfo/PeerInfo.tsx
  • packages/ui-voip/src/components/PeerInfo/index.ts
  • packages/ui-voip/src/context/definitions.d.ts
  • packages/ui-voip/src/context/usePeekMediaSessionPeerInfo.spec.tsx
  • packages/ui-voip/src/context/usePeerAutocomplete.spec.tsx
  • packages/ui-voip/src/context/usePeerAutocomplete.ts
  • packages/ui-voip/src/hooks/useMediaCallAction.spec.tsx
  • packages/ui-voip/src/hooks/useMediaCallAction.ts
  • packages/ui-voip/src/providers/MockedMediaCallProvider.tsx
  • packages/ui-voip/src/providers/useMediaSession.ts
  • packages/ui-voip/src/utils/derivePeerInfoFromInstanceContact.spec.ts
  • packages/ui-voip/src/utils/derivePeerInfoFromInstanceContact.ts
  • packages/ui-voip/src/utils/derivePeerInfoFromInstanceState.spec.ts
  • packages/ui-voip/src/utils/derivePeerInfoFromInstanceState.ts
  • packages/ui-voip/src/views/CallHistoryContextualbar/CallHistoryContextualbar.tsx
  • packages/ui-voip/src/views/MediaCallHistoryTable/CallHistoryTableRow.tsx
  • packages/ui-voip/src/views/MediaCallHistoryTable/MediaCallHistoryTable.stories.tsx
  • packages/ui-voip/src/views/MediaCallWidget/OngoingCall.tsx
  • packages/ui-voip/src/views/MediaCallWidget/OngoingCallWithScreen.tsx
📜 Review details
⏰ Context from checks skipped due to timeout of 90000ms. You can increase the timeout in your CodeRabbit configuration to a maximum of 15 minutes (900000ms). (2)
  • GitHub Check: 📦 Build Packages
  • GitHub Check: CodeQL-Build
🧰 Additional context used
📓 Path-based instructions (2)
**/*.{ts,tsx,js}

📄 CodeRabbit inference engine (.cursor/rules/playwright.mdc)

**/*.{ts,tsx,js}: Write concise, technical TypeScript/JavaScript with accurate typing in Playwright tests
Avoid code comments in the implementation

Files:

  • packages/ui-voip/src/views/MediaCallHistoryTable/CallHistoryTableRow.tsx
  • apps/meteor/server/startup/migrations/v336.ts
  • packages/ui-voip/src/views/CallHistoryContextualbar/CallHistoryContextualbar.tsx
  • packages/ui-voip/src/hooks/useMediaCallAction.ts
  • packages/ui-voip/src/utils/derivePeerInfoFromInstanceState.ts
  • packages/ui-voip/src/components/PeerInfo/ExternalUser.tsx
  • apps/meteor/client/views/mediaCallHistory/CallHistoryPage.tsx
  • ee/packages/media-calls/src/definition/IMediaCallServer.ts
  • packages/ui-voip/src/components/PeerInfo/index.ts
  • packages/ui-voip/src/components/PeerInfo/PeerInfo.tsx
  • ee/packages/media-calls/src/definition/IMediaCallCastDirector.ts
  • apps/meteor/server/startup/migrations/index.ts
  • packages/core-typings/src/ICallHistoryItem.ts
  • packages/ui-voip/src/components/PeerInfo/InternalUser.tsx
  • packages/ui-voip/src/views/MediaCallHistoryTable/MediaCallHistoryTable.stories.tsx
  • packages/ui-voip/src/utils/derivePeerInfoFromInstanceState.spec.ts
  • packages/model-typings/src/models/IUsersModel.ts
  • packages/ui-voip/src/views/MediaCallWidget/OngoingCallWithScreen.tsx
  • apps/meteor/client/views/mediaCallHistory/MediaCallHistoryExternal.tsx
  • packages/ui-voip/src/context/usePeerAutocomplete.ts
  • packages/ui-voip/src/components/CallHistoryExternalUser.tsx
  • packages/ui-voip/src/context/definitions.d.ts
  • packages/ui-voip/src/context/usePeekMediaSessionPeerInfo.spec.tsx
  • packages/ui-voip/src/providers/useMediaSession.ts
  • packages/ui-voip/src/views/MediaCallWidget/OngoingCall.tsx
  • ee/packages/media-calls/src/server/getDefaultSettings.ts
  • ee/packages/media-calls/src/sip/providers/IncomingSipCall.ts
  • packages/ui-voip/src/components/PeerInfo/PeerInfo.stories.tsx
  • packages/ui-voip/src/utils/derivePeerInfoFromInstanceContact.ts
  • apps/meteor/app/api/server/v1/call-history.ts
  • packages/ui-voip/src/providers/MockedMediaCallProvider.tsx
  • packages/ui-voip/src/utils/derivePeerInfoFromInstanceContact.spec.ts
  • packages/ui-voip/src/context/usePeerAutocomplete.spec.tsx
  • apps/meteor/server/services/media-call/service.ts
  • apps/meteor/ee/server/settings/voip.ts
  • ee/packages/media-calls/src/server/CastDirector.ts
  • packages/ui-voip/src/hooks/useMediaCallAction.spec.tsx
  • ee/packages/media-calls/src/server/MediaCallServer.ts
  • packages/models/src/models/Users.ts
**/*.spec.ts

📄 CodeRabbit inference engine (.cursor/rules/playwright.mdc)

**/*.spec.ts: Use descriptive test names that clearly communicate expected behavior in Playwright tests
Use .spec.ts extension for test files (e.g., login.spec.ts)

Files:

  • packages/ui-voip/src/utils/derivePeerInfoFromInstanceState.spec.ts
  • packages/ui-voip/src/utils/derivePeerInfoFromInstanceContact.spec.ts
🧠 Learnings (11)
📚 Learning: 2026-02-26T19:22:29.385Z
Learnt from: gabriellsh
Repo: RocketChat/Rocket.Chat PR: 38778
File: packages/ui-voip/src/views/CallHistoryContextualbar/CallHistoryActions.tsx:40-40
Timestamp: 2026-02-26T19:22:29.385Z
Learning: For TSX files in the UI VOIP package, ensure that when a media session state is 'unavailable', the voiceCall action is excluded from the actions object passed to CallHistoryActions so it does not render in the menu. This filtering should occur upstream (before getItems is called) to avoid tooltips or UI hints for unavailable actions. If there are multiple actions with availability states, implement a centralized helper to filter actions based on session state.

Applied to files:

  • packages/ui-voip/src/views/MediaCallHistoryTable/CallHistoryTableRow.tsx
  • packages/ui-voip/src/views/CallHistoryContextualbar/CallHistoryContextualbar.tsx
  • packages/ui-voip/src/components/PeerInfo/ExternalUser.tsx
  • packages/ui-voip/src/components/PeerInfo/PeerInfo.tsx
  • packages/ui-voip/src/components/PeerInfo/InternalUser.tsx
  • packages/ui-voip/src/views/MediaCallHistoryTable/MediaCallHistoryTable.stories.tsx
  • packages/ui-voip/src/views/MediaCallWidget/OngoingCallWithScreen.tsx
  • packages/ui-voip/src/components/CallHistoryExternalUser.tsx
  • packages/ui-voip/src/context/usePeekMediaSessionPeerInfo.spec.tsx
  • packages/ui-voip/src/views/MediaCallWidget/OngoingCall.tsx
  • packages/ui-voip/src/components/PeerInfo/PeerInfo.stories.tsx
  • packages/ui-voip/src/providers/MockedMediaCallProvider.tsx
  • packages/ui-voip/src/context/usePeerAutocomplete.spec.tsx
  • packages/ui-voip/src/hooks/useMediaCallAction.spec.tsx
📚 Learning: 2026-05-05T12:34:29.042Z
Learnt from: gabriellsh
Repo: RocketChat/Rocket.Chat PR: 40331
File: packages/ui-voip/src/views/MediaCallWidget/OngoingCallWithScreen.tsx:69-69
Timestamp: 2026-05-05T12:34:29.042Z
Learning: In Rocket.Chat’s `packages/ui-voip` UI (e.g., media/call widgets), voice/media calls are only supported in Direct Message (DM) rooms. Rocket.Chat models a DM as a “room” with exactly two participants, so handlers like `onClickDirectMessage` are the correct destination—even when the UI text/element says “Open in room” (e.g., on the shared screen card/`StreamCard`). During review, don’t flag a “DM vs room” mismatch for these cases; they intentionally map to the same destination.

Applied to files:

  • packages/ui-voip/src/views/MediaCallHistoryTable/CallHistoryTableRow.tsx
  • packages/ui-voip/src/views/CallHistoryContextualbar/CallHistoryContextualbar.tsx
  • packages/ui-voip/src/components/PeerInfo/ExternalUser.tsx
  • packages/ui-voip/src/components/PeerInfo/PeerInfo.tsx
  • packages/ui-voip/src/components/PeerInfo/InternalUser.tsx
  • packages/ui-voip/src/views/MediaCallHistoryTable/MediaCallHistoryTable.stories.tsx
  • packages/ui-voip/src/views/MediaCallWidget/OngoingCallWithScreen.tsx
  • packages/ui-voip/src/components/CallHistoryExternalUser.tsx
  • packages/ui-voip/src/context/usePeekMediaSessionPeerInfo.spec.tsx
  • packages/ui-voip/src/views/MediaCallWidget/OngoingCall.tsx
  • packages/ui-voip/src/components/PeerInfo/PeerInfo.stories.tsx
  • packages/ui-voip/src/providers/MockedMediaCallProvider.tsx
  • packages/ui-voip/src/context/usePeerAutocomplete.spec.tsx
  • packages/ui-voip/src/hooks/useMediaCallAction.spec.tsx
📚 Learning: 2026-03-27T14:52:56.865Z
Learnt from: dougfabris
Repo: RocketChat/Rocket.Chat PR: 39892
File: apps/meteor/client/views/room/contextualBar/Threads/Thread.tsx:150-155
Timestamp: 2026-03-27T14:52:56.865Z
Learning: In Rocket.Chat, there are two different `ModalBackdrop` components with different prop APIs. During review, confirm the import source: (1) `rocket.chat/fuselage` `ModalBackdrop` uses `ModalBackdropProps` based on `BoxProps` (so it supports `onClick` and other Box/DOM props) and does not have an `onDismiss` prop; (2) `rocket.chat/ui-client` `ModalBackdrop` uses a narrower props interface like `{ children?: ReactNode; onDismiss?: () => void }` and handles Escape keypress and outside mouse-up, and it does not forward arbitrary DOM props such as `onClick`. Flag mismatched props (e.g., `onDismiss` passed to the fuselage component or `onClick` passed to the ui-client component) and ensure the usage matches the correct component being imported.

Applied to files:

  • packages/ui-voip/src/views/MediaCallHistoryTable/CallHistoryTableRow.tsx
  • packages/ui-voip/src/views/CallHistoryContextualbar/CallHistoryContextualbar.tsx
  • packages/ui-voip/src/components/PeerInfo/ExternalUser.tsx
  • apps/meteor/client/views/mediaCallHistory/CallHistoryPage.tsx
  • packages/ui-voip/src/components/PeerInfo/PeerInfo.tsx
  • packages/ui-voip/src/components/PeerInfo/InternalUser.tsx
  • packages/ui-voip/src/views/MediaCallHistoryTable/MediaCallHistoryTable.stories.tsx
  • packages/ui-voip/src/views/MediaCallWidget/OngoingCallWithScreen.tsx
  • apps/meteor/client/views/mediaCallHistory/MediaCallHistoryExternal.tsx
  • packages/ui-voip/src/components/CallHistoryExternalUser.tsx
  • packages/ui-voip/src/context/usePeekMediaSessionPeerInfo.spec.tsx
  • packages/ui-voip/src/views/MediaCallWidget/OngoingCall.tsx
  • packages/ui-voip/src/components/PeerInfo/PeerInfo.stories.tsx
  • packages/ui-voip/src/providers/MockedMediaCallProvider.tsx
  • packages/ui-voip/src/context/usePeerAutocomplete.spec.tsx
  • packages/ui-voip/src/hooks/useMediaCallAction.spec.tsx
📚 Learning: 2026-05-06T12:21:44.083Z
Learnt from: juliajforesti
Repo: RocketChat/Rocket.Chat PR: 40256
File: apps/meteor/client/components/CreateDiscussion/CreateDiscussion.tsx:121-149
Timestamp: 2026-05-06T12:21:44.083Z
Learning: Field wrappers in rocket.chat/fuselage-forms (Field, FieldLabel, FieldRow, FieldError, FieldHint) auto-create htmlFor/id associations, aria-describedby, and role="alert" for errors. Do not manually set htmlFor, id, aria-describedby, or role attributes when using these wrappers. This automatic wiring does not apply to plain rocket.chat/fuselage components, which require explicit ID wiring per the accessibility docs. In code reviews, prefer using fuselage-forms wrappers for form fields and verify there is no unnecessary manual ID/aria wiring in files that use these wrappers. If a component uses plain fuselage components, ensure proper id wiring as per docs.

Applied to files:

  • packages/ui-voip/src/views/MediaCallHistoryTable/CallHistoryTableRow.tsx
  • apps/meteor/server/startup/migrations/v336.ts
  • packages/ui-voip/src/views/CallHistoryContextualbar/CallHistoryContextualbar.tsx
  • packages/ui-voip/src/hooks/useMediaCallAction.ts
  • packages/ui-voip/src/utils/derivePeerInfoFromInstanceState.ts
  • packages/ui-voip/src/components/PeerInfo/ExternalUser.tsx
  • apps/meteor/client/views/mediaCallHistory/CallHistoryPage.tsx
  • ee/packages/media-calls/src/definition/IMediaCallServer.ts
  • packages/ui-voip/src/components/PeerInfo/index.ts
  • packages/ui-voip/src/components/PeerInfo/PeerInfo.tsx
  • ee/packages/media-calls/src/definition/IMediaCallCastDirector.ts
  • apps/meteor/server/startup/migrations/index.ts
  • packages/core-typings/src/ICallHistoryItem.ts
  • packages/ui-voip/src/components/PeerInfo/InternalUser.tsx
  • packages/ui-voip/src/views/MediaCallHistoryTable/MediaCallHistoryTable.stories.tsx
  • packages/ui-voip/src/utils/derivePeerInfoFromInstanceState.spec.ts
  • packages/model-typings/src/models/IUsersModel.ts
  • packages/ui-voip/src/views/MediaCallWidget/OngoingCallWithScreen.tsx
  • apps/meteor/client/views/mediaCallHistory/MediaCallHistoryExternal.tsx
  • packages/ui-voip/src/context/usePeerAutocomplete.ts
  • packages/ui-voip/src/components/CallHistoryExternalUser.tsx
  • packages/ui-voip/src/context/definitions.d.ts
  • packages/ui-voip/src/context/usePeekMediaSessionPeerInfo.spec.tsx
  • packages/ui-voip/src/providers/useMediaSession.ts
  • packages/ui-voip/src/views/MediaCallWidget/OngoingCall.tsx
  • ee/packages/media-calls/src/server/getDefaultSettings.ts
  • ee/packages/media-calls/src/sip/providers/IncomingSipCall.ts
  • packages/ui-voip/src/components/PeerInfo/PeerInfo.stories.tsx
  • packages/ui-voip/src/utils/derivePeerInfoFromInstanceContact.ts
  • apps/meteor/app/api/server/v1/call-history.ts
  • packages/ui-voip/src/providers/MockedMediaCallProvider.tsx
  • packages/ui-voip/src/utils/derivePeerInfoFromInstanceContact.spec.ts
  • packages/ui-voip/src/context/usePeerAutocomplete.spec.tsx
  • apps/meteor/server/services/media-call/service.ts
  • apps/meteor/ee/server/settings/voip.ts
  • ee/packages/media-calls/src/server/CastDirector.ts
  • packages/ui-voip/src/hooks/useMediaCallAction.spec.tsx
  • ee/packages/media-calls/src/server/MediaCallServer.ts
  • packages/models/src/models/Users.ts
📚 Learning: 2026-02-26T19:25:44.063Z
Learnt from: gabriellsh
Repo: RocketChat/Rocket.Chat PR: 38778
File: packages/ui-voip/src/providers/useMediaSession.ts:192-192
Timestamp: 2026-02-26T19:25:44.063Z
Learning: In the Rocket.Chat repository, do not reference Biome lint rules in code review feedback. Biome is not used even if biome.json exists; only reference Biome rules if there is explicit, project-wide usage documented. For TypeScript files, review lint implications without Biome guidance unless the project enables Biome rules.

Applied to files:

  • apps/meteor/server/startup/migrations/v336.ts
  • packages/ui-voip/src/hooks/useMediaCallAction.ts
  • packages/ui-voip/src/utils/derivePeerInfoFromInstanceState.ts
  • ee/packages/media-calls/src/definition/IMediaCallServer.ts
  • packages/ui-voip/src/components/PeerInfo/index.ts
  • ee/packages/media-calls/src/definition/IMediaCallCastDirector.ts
  • apps/meteor/server/startup/migrations/index.ts
  • packages/core-typings/src/ICallHistoryItem.ts
  • packages/ui-voip/src/utils/derivePeerInfoFromInstanceState.spec.ts
  • packages/model-typings/src/models/IUsersModel.ts
  • packages/ui-voip/src/context/usePeerAutocomplete.ts
  • packages/ui-voip/src/context/definitions.d.ts
  • packages/ui-voip/src/providers/useMediaSession.ts
  • ee/packages/media-calls/src/server/getDefaultSettings.ts
  • ee/packages/media-calls/src/sip/providers/IncomingSipCall.ts
  • packages/ui-voip/src/utils/derivePeerInfoFromInstanceContact.ts
  • apps/meteor/app/api/server/v1/call-history.ts
  • packages/ui-voip/src/utils/derivePeerInfoFromInstanceContact.spec.ts
  • apps/meteor/server/services/media-call/service.ts
  • apps/meteor/ee/server/settings/voip.ts
  • ee/packages/media-calls/src/server/CastDirector.ts
  • ee/packages/media-calls/src/server/MediaCallServer.ts
  • packages/models/src/models/Users.ts
📚 Learning: 2026-02-26T19:25:44.063Z
Learnt from: gabriellsh
Repo: RocketChat/Rocket.Chat PR: 38778
File: packages/ui-voip/src/providers/useMediaSession.ts:192-192
Timestamp: 2026-02-26T19:25:44.063Z
Learning: In this repository (RocketChat/Rocket.Chat), Biome lint rules are not used even if a biome.json exists. When reviewing TypeScript files (e.g., packages/ui-voip/src/providers/useMediaSession.ts), ensure lint suggestions do not reference Biome-specific rules. Rely on general ESLint/TypeScript lint rules and project conventions instead.

Applied to files:

  • apps/meteor/server/startup/migrations/v336.ts
  • packages/ui-voip/src/hooks/useMediaCallAction.ts
  • packages/ui-voip/src/utils/derivePeerInfoFromInstanceState.ts
  • ee/packages/media-calls/src/definition/IMediaCallServer.ts
  • packages/ui-voip/src/components/PeerInfo/index.ts
  • ee/packages/media-calls/src/definition/IMediaCallCastDirector.ts
  • apps/meteor/server/startup/migrations/index.ts
  • packages/core-typings/src/ICallHistoryItem.ts
  • packages/ui-voip/src/utils/derivePeerInfoFromInstanceState.spec.ts
  • packages/model-typings/src/models/IUsersModel.ts
  • packages/ui-voip/src/context/usePeerAutocomplete.ts
  • packages/ui-voip/src/context/definitions.d.ts
  • packages/ui-voip/src/providers/useMediaSession.ts
  • ee/packages/media-calls/src/server/getDefaultSettings.ts
  • ee/packages/media-calls/src/sip/providers/IncomingSipCall.ts
  • packages/ui-voip/src/utils/derivePeerInfoFromInstanceContact.ts
  • apps/meteor/app/api/server/v1/call-history.ts
  • packages/ui-voip/src/utils/derivePeerInfoFromInstanceContact.spec.ts
  • apps/meteor/server/services/media-call/service.ts
  • apps/meteor/ee/server/settings/voip.ts
  • ee/packages/media-calls/src/server/CastDirector.ts
  • ee/packages/media-calls/src/server/MediaCallServer.ts
  • packages/models/src/models/Users.ts
📚 Learning: 2025-12-10T21:00:43.645Z
Learnt from: KevLehman
Repo: RocketChat/Rocket.Chat PR: 37091
File: ee/packages/abac/jest.config.ts:4-7
Timestamp: 2025-12-10T21:00:43.645Z
Learning: Adopt the monorepo-wide Jest testMatch pattern: <rootDir>/src/**/*.spec.{ts,js,mjs} (represented here as '**/src/**/*.spec.{ts,js,mjs}') to ensure spec files under any package's src directory are picked up consistently across all packages in the Rocket.Chat monorepo. Apply this pattern in jest.config.ts for all relevant packages to maintain uniform test discovery.

Applied to files:

  • packages/ui-voip/src/utils/derivePeerInfoFromInstanceState.spec.ts
  • packages/ui-voip/src/utils/derivePeerInfoFromInstanceContact.spec.ts
📚 Learning: 2026-02-24T19:22:48.358Z
Learnt from: juliajforesti
Repo: RocketChat/Rocket.Chat PR: 38493
File: apps/meteor/tests/e2e/omnichannel/omnichannel-send-pdf-transcript.spec.ts:66-67
Timestamp: 2026-02-24T19:22:48.358Z
Learning: In Playwright end-to-end tests (e.g., under apps/meteor/tests/e2e/...), prefer locating elements by translated text (getByText) and ARIA roles (getByRole) over data-qa attributes. If translation values change, update the corresponding test locators accordingly. Never use data-qa locators. This guideline applies to all Playwright e2e test specs in the repository and helps keep tests robust to UI text changes and accessible semantics.

Applied to files:

  • packages/ui-voip/src/utils/derivePeerInfoFromInstanceState.spec.ts
  • packages/ui-voip/src/utils/derivePeerInfoFromInstanceContact.spec.ts
📚 Learning: 2026-03-06T18:10:15.268Z
Learnt from: tassoevan
Repo: RocketChat/Rocket.Chat PR: 39397
File: packages/gazzodown/src/code/CodeBlock.spec.tsx:47-68
Timestamp: 2026-03-06T18:10:15.268Z
Learning: In tests (especially those using testing-library/dom/jsdom) for Rocket.Chat components, the HTML <code> element has an implicit ARIA role of 'code'. Therefore, screen.getByRole('code') or screen.findByRole('code') will locate <code> elements even without a role attribute. Do not flag findByRole('code') as invalid in reviews; prefer using the implicit role instead of adding role="code" unless necessary for accessibility.

Applied to files:

  • packages/ui-voip/src/utils/derivePeerInfoFromInstanceState.spec.ts
  • packages/ui-voip/src/context/usePeekMediaSessionPeerInfo.spec.tsx
  • packages/ui-voip/src/utils/derivePeerInfoFromInstanceContact.spec.ts
  • packages/ui-voip/src/context/usePeerAutocomplete.spec.tsx
  • packages/ui-voip/src/hooks/useMediaCallAction.spec.tsx
📚 Learning: 2026-02-23T17:53:06.802Z
Learnt from: ggazzo
Repo: RocketChat/Rocket.Chat PR: 35995
File: apps/meteor/app/api/server/v1/rooms.ts:1107-1112
Timestamp: 2026-02-23T17:53:06.802Z
Learning: During PR reviews that touch endpoint files under apps/meteor/app/api/server/v1, enforce strict scope: if a PR targets a specific endpoint (e.g., rooms.favorite), do not propose changes to unrelated endpoints (e.g., rooms.invite) unless maintainers explicitly request them. Focus feedback on the touched endpoint's behavior, API surface, and related tests; avoid broad cross-endpoint changes in the same PR unless requested.

Applied to files:

  • apps/meteor/app/api/server/v1/call-history.ts
📚 Learning: 2026-02-24T19:09:01.522Z
Learnt from: ahmed-n-abdeltwab
Repo: RocketChat/Rocket.Chat PR: 38974
File: apps/meteor/app/api/server/v1/im.ts:220-221
Timestamp: 2026-02-24T19:09:01.522Z
Learning: In Rocket.Chat OpenAPI migration PRs for endpoints under apps/meteor/app/api/server/v1, avoid introducing logic changes. Only perform scope-tight changes that preserve behavior; style-only cleanups (e.g., removing inline comments) may be deferred to follow-ups to keep the migration PR focused.

Applied to files:

  • apps/meteor/app/api/server/v1/call-history.ts
🔇 Additional comments (42)
packages/ui-voip/src/components/PeerInfo/InternalUser.tsx (1)

6-6: LGTM!

packages/ui-voip/src/context/definitions.d.ts (1)

5-5: LGTM!

Also applies to: 15-18

packages/ui-voip/src/utils/derivePeerInfoFromInstanceState.ts (1)

8-8: LGTM!

packages/ui-voip/src/providers/MockedMediaCallProvider.tsx (1)

36-36: LGTM!

Also applies to: 89-89

packages/ui-voip/src/utils/derivePeerInfoFromInstanceState.spec.ts (1)

32-32: LGTM!

Also applies to: 72-72, 108-108

packages/ui-voip/src/utils/derivePeerInfoFromInstanceContact.ts (1)

11-11: LGTM!

Also applies to: 13-13, 23-23

packages/ui-voip/src/utils/derivePeerInfoFromInstanceContact.spec.ts (1)

13-13: LGTM!

Also applies to: 23-23, 34-34, 39-50, 63-63, 76-76, 93-93, 108-108

packages/ui-voip/src/providers/useMediaSession.ts (1)

145-145: LGTM!

Also applies to: 178-188, 194-197, 214-217

packages/ui-voip/src/hooks/useMediaCallAction.ts (1)

25-25: LGTM!

packages/ui-voip/src/context/usePeekMediaSessionPeerInfo.spec.tsx (1)

76-76: LGTM!

Also applies to: 101-101, 135-135, 159-159

packages/ui-voip/src/context/usePeerAutocomplete.ts (1)

68-68: LGTM!

Also applies to: 79-79

packages/ui-voip/src/hooks/useMediaCallAction.spec.tsx (1)

128-128: LGTM!

Also applies to: 169-169, 181-181, 195-195, 209-209

packages/ui-voip/src/components/PeerInfo/ExternalUser.tsx (1)

4-8: LGTM!

Also applies to: 10-16, 18-18

packages/ui-voip/src/components/PeerInfo/PeerInfo.tsx (1)

5-5: LGTM!

Also applies to: 8-9, 12-12

packages/ui-voip/src/components/PeerInfo/index.ts (1)

2-2: LGTM!

packages/ui-voip/src/components/PeerInfo/PeerInfo.stories.tsx (1)

65-66: LGTM!

Also applies to: 68-70, 72-90

packages/ui-voip/src/views/MediaCallWidget/OngoingCallWithScreen.tsx (1)

66-66: LGTM!

Also applies to: 108-110

packages/ui-voip/src/views/MediaCallWidget/OngoingCall.tsx (1)

53-53: LGTM!

Also applies to: 77-79

packages/ui-voip/src/context/usePeerAutocomplete.spec.tsx (1)

122-122: LGTM!

Also applies to: 133-133, 168-168, 190-190, 251-251, 272-272, 306-306, 324-324

packages/i18n/src/locales/pt-BR.i18n.json (1)

5842-5845: LGTM!

packages/i18n/src/locales/en.i18n.json (1)

5862-5865: LGTM!

ee/packages/media-calls/src/sip/providers/IncomingSipCall.ts (1)

459-484: LGTM!

Also applies to: 490-490, 492-492

ee/packages/media-calls/src/definition/IMediaCallCastDirector.ts (1)

7-12: LGTM!

Also applies to: 39-39

apps/meteor/ee/server/settings/voip.ts (1)

42-76: LGTM!

Also applies to: 81-81, 88-88, 95-95, 102-102, 109-109

apps/meteor/server/startup/migrations/index.ts (1)

44-44: LGTM!

ee/packages/media-calls/src/server/getDefaultSettings.ts (1)

11-14: LGTM!

apps/meteor/client/views/mediaCallHistory/MediaCallHistoryExternal.tsx (1)

18-19: LGTM!

apps/meteor/client/views/mediaCallHistory/CallHistoryPage.tsx (1)

137-137: LGTM!

ee/packages/media-calls/src/server/MediaCallServer.ts (1)

13-13: LGTM!

Also applies to: 144-144

apps/meteor/app/api/server/v1/call-history.ts (1)

124-135: LGTM!

packages/ui-voip/src/views/MediaCallHistoryTable/MediaCallHistoryTable.stories.tsx (1)

81-90: LGTM!

ee/packages/media-calls/src/definition/IMediaCallServer.ts (1)

25-28: LGTM!

packages/core-typings/src/ICallHistoryItem.ts (1)

51-52: LGTM!

apps/meteor/server/services/media-call/service.ts (2)

186-200: LGTM!


392-395: LGTM!

packages/ui-voip/src/views/CallHistoryContextualbar/CallHistoryContextualbar.tsx (2)

33-34: LGTM!


86-86: LGTM!

apps/meteor/server/startup/migrations/v336.ts (1)

5-25: LGTM!

packages/model-typings/src/models/IUsersModel.ts (1)

445-445: LGTM!

packages/ui-voip/src/views/MediaCallHistoryTable/CallHistoryTableRow.tsx (1)

14-15: LGTM!

Also applies to: 71-73

packages/ui-voip/src/components/CallHistoryExternalUser.tsx (1)

1-3: LGTM!

Also applies to: 7-8, 12-19, 22-22, 28-31

ee/packages/media-calls/src/server/CastDirector.ts (1)

5-8: LGTM!

Also applies to: 16-20, 93-94, 102-126

@aleksandernsilva aleksandernsilva force-pushed the feat/voice-identity-lookup branch 3 times, most recently from 22816c4 to 9213b67 Compare May 12, 2026 18:54
@aleksandernsilva aleksandernsilva marked this pull request as ready for review May 12, 2026 21:09
@aleksandernsilva aleksandernsilva requested review from a team as code owners May 12, 2026 21:09
Copy link
Copy Markdown
Contributor

@coderabbitai coderabbitai Bot left a comment

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 `@ee/packages/media-calls/src/sip/providers/IncomingSipCall.ts`:
- Around line 442-467: getDisplayNameFromInvite returns early when a
higher-priority header exists but normalizes to an empty/whitespace string;
update the checks in getDisplayNameFromInvite so that after calling removeQuotes
on each header value (X-RocketChat-Caller-Name, p-asserted-identity.name,
from.name) you only return that value if the result is non-empty (e.g., trimmed
length > 0), otherwise continue to the next header; ensure removeQuotes is used
consistently for all three header branches so empty/whitespace names are skipped
and lower-priority headers can be considered.
🪄 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: Organization UI

Review profile: CHILL

Plan: Pro

Run ID: 55117612-aef2-4b1c-9cc9-888f10b1411c

📥 Commits

Reviewing files that changed from the base of the PR and between 060cfd3 and 9213b67.

⛔ Files ignored due to path filters (3)
  • packages/ui-voip/src/components/PeerInfo/__snapshots__/PeerInfo.spec.tsx.snap is excluded by !**/*.snap
  • packages/ui-voip/src/views/CallHistoryContextualbar/__snapshots__/CallHistoryContextualbar.spec.tsx.snap is excluded by !**/*.snap
  • packages/ui-voip/src/views/MediaCallHistoryTable/__snapshots__/MediaCallHistoryTable.spec.tsx.snap is excluded by !**/*.snap
📒 Files selected for processing (40)
  • apps/meteor/app/api/server/v1/call-history.ts
  • apps/meteor/client/views/mediaCallHistory/CallHistoryPage.tsx
  • apps/meteor/client/views/mediaCallHistory/MediaCallHistoryExternal.tsx
  • apps/meteor/ee/server/settings/voip.ts
  • apps/meteor/server/services/media-call/service.ts
  • ee/packages/media-calls/src/definition/IMediaCallCastDirector.ts
  • ee/packages/media-calls/src/definition/IMediaCallServer.ts
  • ee/packages/media-calls/src/definition/common.ts
  • ee/packages/media-calls/src/server/CastDirector.ts
  • ee/packages/media-calls/src/server/MediaCallServer.ts
  • ee/packages/media-calls/src/server/getDefaultSettings.ts
  • ee/packages/media-calls/src/sip/providers/IncomingSipCall.ts
  • packages/core-typings/src/ICallHistoryItem.ts
  • packages/i18n/src/locales/en.i18n.json
  • packages/i18n/src/locales/pt-BR.i18n.json
  • packages/model-typings/src/models/IUsersModel.ts
  • packages/models/src/models/Users.ts
  • packages/ui-voip/src/components/CallHistoryExternalUser.tsx
  • packages/ui-voip/src/components/PeerInfo/ExternalUser.tsx
  • packages/ui-voip/src/components/PeerInfo/InternalUser.tsx
  • packages/ui-voip/src/components/PeerInfo/PeerInfo.stories.tsx
  • packages/ui-voip/src/components/PeerInfo/PeerInfo.tsx
  • packages/ui-voip/src/components/PeerInfo/index.ts
  • packages/ui-voip/src/context/definitions.d.ts
  • packages/ui-voip/src/context/usePeekMediaSessionPeerInfo.spec.tsx
  • packages/ui-voip/src/context/usePeerAutocomplete.spec.tsx
  • packages/ui-voip/src/context/usePeerAutocomplete.ts
  • packages/ui-voip/src/hooks/useMediaCallAction.spec.tsx
  • packages/ui-voip/src/hooks/useMediaCallAction.ts
  • packages/ui-voip/src/providers/MockedMediaCallProvider.tsx
  • packages/ui-voip/src/providers/useMediaSession.ts
  • packages/ui-voip/src/utils/derivePeerInfoFromInstanceContact.spec.ts
  • packages/ui-voip/src/utils/derivePeerInfoFromInstanceContact.ts
  • packages/ui-voip/src/utils/derivePeerInfoFromInstanceState.spec.ts
  • packages/ui-voip/src/utils/derivePeerInfoFromInstanceState.ts
  • packages/ui-voip/src/views/CallHistoryContextualbar/CallHistoryContextualbar.tsx
  • packages/ui-voip/src/views/MediaCallHistoryTable/CallHistoryTableRow.tsx
  • packages/ui-voip/src/views/MediaCallHistoryTable/MediaCallHistoryTable.stories.tsx
  • packages/ui-voip/src/views/MediaCallWidget/OngoingCall.tsx
  • packages/ui-voip/src/views/MediaCallWidget/OngoingCallWithScreen.tsx
💤 Files with no reviewable changes (1)
  • apps/meteor/app/api/server/v1/call-history.ts
✅ Files skipped from review due to trivial changes (3)
  • packages/ui-voip/src/providers/MockedMediaCallProvider.tsx
  • packages/ui-voip/src/utils/derivePeerInfoFromInstanceContact.spec.ts
  • packages/i18n/src/locales/pt-BR.i18n.json
🚧 Files skipped from review as they are similar to previous changes (31)
  • packages/ui-voip/src/hooks/useMediaCallAction.ts
  • packages/ui-voip/src/utils/derivePeerInfoFromInstanceState.spec.ts
  • apps/meteor/client/views/mediaCallHistory/MediaCallHistoryExternal.tsx
  • ee/packages/media-calls/src/definition/IMediaCallServer.ts
  • packages/ui-voip/src/components/PeerInfo/ExternalUser.tsx
  • packages/ui-voip/src/components/PeerInfo/InternalUser.tsx
  • packages/ui-voip/src/utils/derivePeerInfoFromInstanceState.ts
  • ee/packages/media-calls/src/server/getDefaultSettings.ts
  • packages/core-typings/src/ICallHistoryItem.ts
  • packages/ui-voip/src/views/CallHistoryContextualbar/CallHistoryContextualbar.tsx
  • packages/ui-voip/src/views/MediaCallWidget/OngoingCall.tsx
  • packages/ui-voip/src/views/MediaCallHistoryTable/CallHistoryTableRow.tsx
  • packages/ui-voip/src/hooks/useMediaCallAction.spec.tsx
  • packages/ui-voip/src/providers/useMediaSession.ts
  • ee/packages/media-calls/src/definition/IMediaCallCastDirector.ts
  • apps/meteor/server/services/media-call/service.ts
  • packages/ui-voip/src/components/PeerInfo/index.ts
  • packages/i18n/src/locales/en.i18n.json
  • packages/models/src/models/Users.ts
  • packages/ui-voip/src/components/PeerInfo/PeerInfo.stories.tsx
  • packages/ui-voip/src/utils/derivePeerInfoFromInstanceContact.ts
  • packages/model-typings/src/models/IUsersModel.ts
  • packages/ui-voip/src/views/MediaCallWidget/OngoingCallWithScreen.tsx
  • packages/ui-voip/src/components/PeerInfo/PeerInfo.tsx
  • packages/ui-voip/src/context/usePeekMediaSessionPeerInfo.spec.tsx
  • apps/meteor/ee/server/settings/voip.ts
  • packages/ui-voip/src/views/MediaCallHistoryTable/MediaCallHistoryTable.stories.tsx
  • packages/ui-voip/src/context/usePeerAutocomplete.spec.tsx
  • ee/packages/media-calls/src/server/CastDirector.ts
  • packages/ui-voip/src/context/definitions.d.ts
  • packages/ui-voip/src/components/CallHistoryExternalUser.tsx
📜 Review details
🧰 Additional context used
📓 Path-based instructions (1)
**/*.{ts,tsx,js}

📄 CodeRabbit inference engine (.cursor/rules/playwright.mdc)

**/*.{ts,tsx,js}: Write concise, technical TypeScript/JavaScript with accurate typing in Playwright tests
Avoid code comments in the implementation

Files:

  • apps/meteor/client/views/mediaCallHistory/CallHistoryPage.tsx
  • ee/packages/media-calls/src/definition/common.ts
  • ee/packages/media-calls/src/server/MediaCallServer.ts
  • ee/packages/media-calls/src/sip/providers/IncomingSipCall.ts
  • packages/ui-voip/src/context/usePeerAutocomplete.ts
🧠 Learnings (4)
📚 Learning: 2026-03-27T14:52:56.865Z
Learnt from: dougfabris
Repo: RocketChat/Rocket.Chat PR: 39892
File: apps/meteor/client/views/room/contextualBar/Threads/Thread.tsx:150-155
Timestamp: 2026-03-27T14:52:56.865Z
Learning: In Rocket.Chat, there are two different `ModalBackdrop` components with different prop APIs. During review, confirm the import source: (1) `rocket.chat/fuselage` `ModalBackdrop` uses `ModalBackdropProps` based on `BoxProps` (so it supports `onClick` and other Box/DOM props) and does not have an `onDismiss` prop; (2) `rocket.chat/ui-client` `ModalBackdrop` uses a narrower props interface like `{ children?: ReactNode; onDismiss?: () => void }` and handles Escape keypress and outside mouse-up, and it does not forward arbitrary DOM props such as `onClick`. Flag mismatched props (e.g., `onDismiss` passed to the fuselage component or `onClick` passed to the ui-client component) and ensure the usage matches the correct component being imported.

Applied to files:

  • apps/meteor/client/views/mediaCallHistory/CallHistoryPage.tsx
📚 Learning: 2026-05-06T12:21:44.083Z
Learnt from: juliajforesti
Repo: RocketChat/Rocket.Chat PR: 40256
File: apps/meteor/client/components/CreateDiscussion/CreateDiscussion.tsx:121-149
Timestamp: 2026-05-06T12:21:44.083Z
Learning: Field wrappers in rocket.chat/fuselage-forms (Field, FieldLabel, FieldRow, FieldError, FieldHint) auto-create htmlFor/id associations, aria-describedby, and role="alert" for errors. Do not manually set htmlFor, id, aria-describedby, or role attributes when using these wrappers. This automatic wiring does not apply to plain rocket.chat/fuselage components, which require explicit ID wiring per the accessibility docs. In code reviews, prefer using fuselage-forms wrappers for form fields and verify there is no unnecessary manual ID/aria wiring in files that use these wrappers. If a component uses plain fuselage components, ensure proper id wiring as per docs.

Applied to files:

  • apps/meteor/client/views/mediaCallHistory/CallHistoryPage.tsx
  • ee/packages/media-calls/src/definition/common.ts
  • ee/packages/media-calls/src/server/MediaCallServer.ts
  • ee/packages/media-calls/src/sip/providers/IncomingSipCall.ts
  • packages/ui-voip/src/context/usePeerAutocomplete.ts
📚 Learning: 2026-02-26T19:25:44.063Z
Learnt from: gabriellsh
Repo: RocketChat/Rocket.Chat PR: 38778
File: packages/ui-voip/src/providers/useMediaSession.ts:192-192
Timestamp: 2026-02-26T19:25:44.063Z
Learning: In the Rocket.Chat repository, do not reference Biome lint rules in code review feedback. Biome is not used even if biome.json exists; only reference Biome rules if there is explicit, project-wide usage documented. For TypeScript files, review lint implications without Biome guidance unless the project enables Biome rules.

Applied to files:

  • ee/packages/media-calls/src/definition/common.ts
  • ee/packages/media-calls/src/server/MediaCallServer.ts
  • ee/packages/media-calls/src/sip/providers/IncomingSipCall.ts
  • packages/ui-voip/src/context/usePeerAutocomplete.ts
📚 Learning: 2026-02-26T19:25:44.063Z
Learnt from: gabriellsh
Repo: RocketChat/Rocket.Chat PR: 38778
File: packages/ui-voip/src/providers/useMediaSession.ts:192-192
Timestamp: 2026-02-26T19:25:44.063Z
Learning: In this repository (RocketChat/Rocket.Chat), Biome lint rules are not used even if a biome.json exists. When reviewing TypeScript files (e.g., packages/ui-voip/src/providers/useMediaSession.ts), ensure lint suggestions do not reference Biome-specific rules. Rely on general ESLint/TypeScript lint rules and project conventions instead.

Applied to files:

  • ee/packages/media-calls/src/definition/common.ts
  • ee/packages/media-calls/src/server/MediaCallServer.ts
  • ee/packages/media-calls/src/sip/providers/IncomingSipCall.ts
  • packages/ui-voip/src/context/usePeerAutocomplete.ts
🔇 Additional comments (6)
ee/packages/media-calls/src/server/MediaCallServer.ts (1)

13-13: LGTM!

apps/meteor/client/views/mediaCallHistory/CallHistoryPage.tsx (1)

137-137: LGTM!

ee/packages/media-calls/src/definition/common.ts (1)

9-9: LGTM!

ee/packages/media-calls/src/sip/providers/IncomingSipCall.ts (1)

472-472: LGTM!

Also applies to: 474-474, 483-487

packages/ui-voip/src/context/usePeerAutocomplete.ts (2)

79-84: LGTM!


68-69: 🏗️ Heavy lift

No action required. The code at lines 68-69 properly implements the discriminated union pattern with complete type safety.

The PeerInfo type is correctly defined in definitions.d.ts as a union of InternalPeerInfo (with external: false) and ExternalPeerInfo (with external: true). The external peer creation at line 68 correctly provides all required fields (external and number), and consumers like TransferModal.tsx properly distinguish between variants using field presence checks ('userId' in peer and 'number' in peer).

Comment thread ee/packages/media-calls/src/sip/providers/IncomingSipCall.ts
Copy link
Copy Markdown
Contributor

@pierre-lehnen-rc pierre-lehnen-rc left a comment

Choose a reason for hiding this comment

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

two issues with the custom field lookup: when an user is found by the custom field, then the data from the IUser is used for everything, with the freeSwitchExtension attribute overriding the actual number from the from header. If that IUser doesn't have a freeSwitchExtension, then the whole user gets discarded and only the values from the headers are shown.

Comment thread ee/packages/media-calls/src/server/CastDirector.ts
Copy link
Copy Markdown
Contributor

@coderabbitai coderabbitai Bot left a comment

Choose a reason for hiding this comment

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

♻️ Duplicate comments (1)
ee/packages/media-calls/src/sip/providers/IncomingSipCall.ts (1)

442-467: ⚠️ Potential issue | 🟡 Minor | ⚡ Quick win

Apply removeQuotes consistently to X-RocketChat-Caller-Name.

The new removeQuotes normalization is applied to p-asserted-identity and from, but the highest-priority X-RocketChat-Caller-Name branch returns the raw header value. As a result:

  • A quoted value like "Alice" is returned with the surrounding quotes intact, inconsistent with the other two branches.
  • A whitespace-only value like " " is truthy and short-circuits the fallback to lower-priority headers, instead of being skipped.

This is the same class of issue raised on the previous revision; the normalization is now partial.

Suggested fix
 	private static getDisplayNameFromInvite(req: SrfRequest): string | undefined {
 		const removeQuotes = (str?: string): string | undefined => str?.replace(/^"|"$/g, '').trim();

 		if (req.has('X-RocketChat-Caller-Name')) {
-			const headerValue = req.get('X-RocketChat-Caller-Name');
+			const headerValue = removeQuotes(req.get('X-RocketChat-Caller-Name'));
 			if (headerValue) {
 				return headerValue;
 			}
 		}
🤖 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 `@ee/packages/media-calls/src/sip/providers/IncomingSipCall.ts` around lines
442 - 467, In getDisplayNameFromInvite, apply the same removeQuotes
normalization to the X-RocketChat-Caller-Name branch: read headerValue =
req.get('X-RocketChat-Caller-Name'), pass it through removeQuotes, and only
return it if the normalized value is truthy; this ensures quoted values like
"Alice" are unquoted and whitespace-only values are skipped so lower-priority
headers (p-asserted-identity, from) can be used.
🤖 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.

Duplicate comments:
In `@ee/packages/media-calls/src/sip/providers/IncomingSipCall.ts`:
- Around line 442-467: In getDisplayNameFromInvite, apply the same removeQuotes
normalization to the X-RocketChat-Caller-Name branch: read headerValue =
req.get('X-RocketChat-Caller-Name'), pass it through removeQuotes, and only
return it if the normalized value is truthy; this ensures quoted values like
"Alice" are unquoted and whitespace-only values are skipped so lower-priority
headers (p-asserted-identity, from) can be used.

ℹ️ Review info
⚙️ Run configuration

Configuration used: Organization UI

Review profile: CHILL

Plan: Pro

Run ID: bcc2cfaf-37f6-4031-8d67-afc50db4e088

📥 Commits

Reviewing files that changed from the base of the PR and between 9213b67 and 2773d4e.

⛔ Files ignored due to path filters (3)
  • packages/ui-voip/src/components/PeerInfo/__snapshots__/PeerInfo.spec.tsx.snap is excluded by !**/*.snap
  • packages/ui-voip/src/views/CallHistoryContextualbar/__snapshots__/CallHistoryContextualbar.spec.tsx.snap is excluded by !**/*.snap
  • packages/ui-voip/src/views/MediaCallHistoryTable/__snapshots__/MediaCallHistoryTable.spec.tsx.snap is excluded by !**/*.snap
📒 Files selected for processing (40)
  • apps/meteor/app/api/server/v1/call-history.ts
  • apps/meteor/client/views/mediaCallHistory/CallHistoryPage.tsx
  • apps/meteor/client/views/mediaCallHistory/MediaCallHistoryExternal.tsx
  • apps/meteor/ee/server/settings/voip.ts
  • apps/meteor/server/services/media-call/service.ts
  • ee/packages/media-calls/src/definition/IMediaCallCastDirector.ts
  • ee/packages/media-calls/src/definition/IMediaCallServer.ts
  • ee/packages/media-calls/src/definition/common.ts
  • ee/packages/media-calls/src/server/CastDirector.ts
  • ee/packages/media-calls/src/server/MediaCallServer.ts
  • ee/packages/media-calls/src/server/getDefaultSettings.ts
  • ee/packages/media-calls/src/sip/providers/IncomingSipCall.ts
  • packages/core-typings/src/ICallHistoryItem.ts
  • packages/i18n/src/locales/en.i18n.json
  • packages/i18n/src/locales/pt-BR.i18n.json
  • packages/model-typings/src/models/IUsersModel.ts
  • packages/models/src/models/Users.ts
  • packages/ui-voip/src/components/CallHistoryExternalUser.tsx
  • packages/ui-voip/src/components/PeerInfo/ExternalUser.tsx
  • packages/ui-voip/src/components/PeerInfo/InternalUser.tsx
  • packages/ui-voip/src/components/PeerInfo/PeerInfo.stories.tsx
  • packages/ui-voip/src/components/PeerInfo/PeerInfo.tsx
  • packages/ui-voip/src/components/PeerInfo/index.ts
  • packages/ui-voip/src/context/definitions.d.ts
  • packages/ui-voip/src/context/usePeekMediaSessionPeerInfo.spec.tsx
  • packages/ui-voip/src/context/usePeerAutocomplete.spec.tsx
  • packages/ui-voip/src/context/usePeerAutocomplete.ts
  • packages/ui-voip/src/hooks/useMediaCallAction.spec.tsx
  • packages/ui-voip/src/hooks/useMediaCallAction.ts
  • packages/ui-voip/src/providers/MockedMediaCallProvider.tsx
  • packages/ui-voip/src/providers/useMediaSession.ts
  • packages/ui-voip/src/utils/derivePeerInfoFromInstanceContact.spec.ts
  • packages/ui-voip/src/utils/derivePeerInfoFromInstanceContact.ts
  • packages/ui-voip/src/utils/derivePeerInfoFromInstanceState.spec.ts
  • packages/ui-voip/src/utils/derivePeerInfoFromInstanceState.ts
  • packages/ui-voip/src/views/CallHistoryContextualbar/CallHistoryContextualbar.tsx
  • packages/ui-voip/src/views/MediaCallHistoryTable/CallHistoryTableRow.tsx
  • packages/ui-voip/src/views/MediaCallHistoryTable/MediaCallHistoryTable.stories.tsx
  • packages/ui-voip/src/views/MediaCallWidget/OngoingCall.tsx
  • packages/ui-voip/src/views/MediaCallWidget/OngoingCallWithScreen.tsx
💤 Files with no reviewable changes (1)
  • apps/meteor/app/api/server/v1/call-history.ts
✅ Files skipped from review due to trivial changes (4)
  • ee/packages/media-calls/src/definition/IMediaCallServer.ts
  • packages/ui-voip/src/hooks/useMediaCallAction.ts
  • packages/ui-voip/src/utils/derivePeerInfoFromInstanceState.spec.ts
  • packages/i18n/src/locales/pt-BR.i18n.json
🚧 Files skipped from review as they are similar to previous changes (33)
  • packages/ui-voip/src/views/CallHistoryContextualbar/CallHistoryContextualbar.tsx
  • ee/packages/media-calls/src/definition/common.ts
  • ee/packages/media-calls/src/server/getDefaultSettings.ts
  • packages/ui-voip/src/components/PeerInfo/index.ts
  • packages/model-typings/src/models/IUsersModel.ts
  • packages/ui-voip/src/components/PeerInfo/InternalUser.tsx
  • packages/ui-voip/src/context/usePeerAutocomplete.ts
  • packages/ui-voip/src/hooks/useMediaCallAction.spec.tsx
  • packages/ui-voip/src/components/PeerInfo/PeerInfo.tsx
  • packages/ui-voip/src/components/PeerInfo/ExternalUser.tsx
  • apps/meteor/client/views/mediaCallHistory/MediaCallHistoryExternal.tsx
  • packages/ui-voip/src/context/definitions.d.ts
  • packages/ui-voip/src/components/CallHistoryExternalUser.tsx
  • packages/ui-voip/src/utils/derivePeerInfoFromInstanceState.ts
  • packages/ui-voip/src/views/MediaCallWidget/OngoingCallWithScreen.tsx
  • ee/packages/media-calls/src/definition/IMediaCallCastDirector.ts
  • packages/ui-voip/src/components/PeerInfo/PeerInfo.stories.tsx
  • packages/ui-voip/src/providers/useMediaSession.ts
  • apps/meteor/ee/server/settings/voip.ts
  • packages/ui-voip/src/providers/MockedMediaCallProvider.tsx
  • apps/meteor/client/views/mediaCallHistory/CallHistoryPage.tsx
  • packages/models/src/models/Users.ts
  • ee/packages/media-calls/src/server/MediaCallServer.ts
  • packages/ui-voip/src/views/MediaCallHistoryTable/CallHistoryTableRow.tsx
  • packages/ui-voip/src/utils/derivePeerInfoFromInstanceContact.ts
  • packages/i18n/src/locales/en.i18n.json
  • packages/ui-voip/src/views/MediaCallHistoryTable/MediaCallHistoryTable.stories.tsx
  • packages/ui-voip/src/context/usePeekMediaSessionPeerInfo.spec.tsx
  • packages/ui-voip/src/utils/derivePeerInfoFromInstanceContact.spec.ts
  • packages/ui-voip/src/context/usePeerAutocomplete.spec.tsx
  • packages/ui-voip/src/views/MediaCallWidget/OngoingCall.tsx
  • packages/core-typings/src/ICallHistoryItem.ts
  • apps/meteor/server/services/media-call/service.ts
📜 Review details
⏰ Context from checks skipped due to timeout of 90000ms. You can increase the timeout in your CodeRabbit configuration to a maximum of 15 minutes (900000ms). (3)
  • GitHub Check: 📦 Build Packages
  • GitHub Check: CodeQL-Build
  • GitHub Check: CodeQL-Build
🧰 Additional context used
📓 Path-based instructions (1)
**/*.{ts,tsx,js}

📄 CodeRabbit inference engine (.cursor/rules/playwright.mdc)

**/*.{ts,tsx,js}: Write concise, technical TypeScript/JavaScript with accurate typing in Playwright tests
Avoid code comments in the implementation

Files:

  • ee/packages/media-calls/src/server/CastDirector.ts
  • ee/packages/media-calls/src/sip/providers/IncomingSipCall.ts
🧠 Learnings (3)
📚 Learning: 2026-02-26T19:25:44.063Z
Learnt from: gabriellsh
Repo: RocketChat/Rocket.Chat PR: 38778
File: packages/ui-voip/src/providers/useMediaSession.ts:192-192
Timestamp: 2026-02-26T19:25:44.063Z
Learning: In the Rocket.Chat repository, do not reference Biome lint rules in code review feedback. Biome is not used even if biome.json exists; only reference Biome rules if there is explicit, project-wide usage documented. For TypeScript files, review lint implications without Biome guidance unless the project enables Biome rules.

Applied to files:

  • ee/packages/media-calls/src/server/CastDirector.ts
  • ee/packages/media-calls/src/sip/providers/IncomingSipCall.ts
📚 Learning: 2026-02-26T19:25:44.063Z
Learnt from: gabriellsh
Repo: RocketChat/Rocket.Chat PR: 38778
File: packages/ui-voip/src/providers/useMediaSession.ts:192-192
Timestamp: 2026-02-26T19:25:44.063Z
Learning: In this repository (RocketChat/Rocket.Chat), Biome lint rules are not used even if a biome.json exists. When reviewing TypeScript files (e.g., packages/ui-voip/src/providers/useMediaSession.ts), ensure lint suggestions do not reference Biome-specific rules. Rely on general ESLint/TypeScript lint rules and project conventions instead.

Applied to files:

  • ee/packages/media-calls/src/server/CastDirector.ts
  • ee/packages/media-calls/src/sip/providers/IncomingSipCall.ts
📚 Learning: 2026-05-06T12:21:44.083Z
Learnt from: juliajforesti
Repo: RocketChat/Rocket.Chat PR: 40256
File: apps/meteor/client/components/CreateDiscussion/CreateDiscussion.tsx:121-149
Timestamp: 2026-05-06T12:21:44.083Z
Learning: Field wrappers in rocket.chat/fuselage-forms (Field, FieldLabel, FieldRow, FieldError, FieldHint) auto-create htmlFor/id associations, aria-describedby, and role="alert" for errors. Do not manually set htmlFor, id, aria-describedby, or role attributes when using these wrappers. This automatic wiring does not apply to plain rocket.chat/fuselage components, which require explicit ID wiring per the accessibility docs. In code reviews, prefer using fuselage-forms wrappers for form fields and verify there is no unnecessary manual ID/aria wiring in files that use these wrappers. If a component uses plain fuselage components, ensure proper id wiring as per docs.

Applied to files:

  • ee/packages/media-calls/src/server/CastDirector.ts
  • ee/packages/media-calls/src/sip/providers/IncomingSipCall.ts
🔇 Additional comments (2)
ee/packages/media-calls/src/sip/providers/IncomingSipCall.ts (1)

472-472: LGTM!

Also applies to: 479-479

ee/packages/media-calls/src/server/CastDirector.ts (1)

5-6: LGTM!

Also applies to: 8-8, 16-20, 99-99, 104-117, 166-170, 175-176

@aleksandernsilva aleksandernsilva force-pushed the feat/voice-identity-lookup branch from d8facc2 to 54a6296 Compare May 26, 2026 16:28
Copy link
Copy Markdown

@hacktron-app hacktron-app Bot left a comment

Choose a reason for hiding this comment

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

4 issues found across 4 files

Severity Count
🟡 Medium 4
Comments Outside Diff (3)

🟡 Medium: Sensitive Information Exposure via URL Query Parameters in OAuth Flow

Location: apps/meteor/server/lib/oauth/passportOAuthCallback.ts:10-51

The OAuth callback handler transmits the user's authentication resumeToken and userId as URL query parameters during the redirect to the /home endpoint. URL parameters are frequently logged by web servers, reverse proxies, and browser history, potentially exposing sensitive credentials to unauthorized parties. An attacker with access to these logs or the user's browser history could use the exposed resumeToken to hijack the user's session.

Steps to Reproduce

  1. Initiate an OAuth login flow (e.g., Google or GitHub).
  2. Monitor the network traffic or server logs during the final redirect to the /home page.
  3. Observe the resumeToken and userId being passed as query parameters in the URL.
# No script needed, the vulnerability is inherent in the URL structure generated by the server.
# Example of how an attacker might find the token in server logs
grep -E \"resumeToken=[a-zA-Z0-9_-]+\" /var/log/rocket-chat/access.log
curl -v \"https://your-rocket-chat-instance.com/_oauth/google?code=...\"

PoC Url: https://your-rocket-chat-instance.com/home?resumeToken=SECRET_TOKEN&userId=USER_ID


🟡 Medium: Potential Denial of Service via MongoDB Aggregation in users.list

Location: apps/meteor/app/api/server/v1/users.ts:557-609

The users.list endpoint allows users to provide arbitrary MongoDB query filters via the query parameter. The isValidQuery function explicitly allows the $regex and $options operators. An attacker can craft a query with a complex regular expression that causes catastrophic backtracking (ReDoS) on the MongoDB instance. Because the regex is executed against all documents in the collection during the $match stage of the aggregation pipeline, this can lead to high CPU consumption on the database server, resulting in a Denial of Service.

Steps to Reproduce

  1. Authenticate as a normal user with view-d-room permission.
  2. Send a GET request to /api/v1/users.list with the following query parameter:
    query={"username":{"$regex":"^(a+)+$","$options":"i"}}
  3. The server parses the query and passes it to isValidQuery, which allows the username field and the $regex operator.
  4. The query is executed in the MongoDB aggregation pipeline, causing high CPU usage due to regex backtracking.

🟡 Medium: Potential Mass-Assignment Vulnerability via Index Signature in ILivechatDepartment

Location: packages/core-typings/src/ILivechatDepartment.ts:1-3

The vulnerability exists due to a combination of factors:

  1. Index Signature: The ILivechatDepartment interface contains an index signature [k: string]: any;, which bypasses TypeScript's strict property checks.
  2. Permissive Schema Validation: The AJV schema POSTLivechatDepartmentSchema explicitly sets additionalProperties: true for the department object. Furthermore, the PUT /api/v1/livechat/department/:_id route does not use AJV validation at all.
  3. Dynamic Validation Bypass: In apps/meteor/app/livechat/server/lib/departmentsLib.ts, the saveDepartment function dynamically adds any extra fields present in the payload to the check validation as long as they are of type String, Match.Integer, or Boolean. This was likely intended for custom fields but inadvertently allows internal fields.
  4. Direct Object Spread: In packages/models/src/models/LivechatDepartment.ts, the createOrUpdateDepartment function directly spreads the input data into the database record (const record = { ...data } as ILivechatDepartment;).

As a result, an attacker with the manage-livechat-departments permission can perform a mass-assignment attack to inject or overwrite internal fields such as numAgents (integer), parentId (string), businessHourId (string), or archived (boolean), which could disrupt routing logic or department hierarchies.

Steps to Reproduce

An attacker with the appropriate permissions can send a PUT request to update a department and inject internal fields:

PUT /api/v1/livechat/department/DEPARTMENT_ID HTTP/1.1
Host: localhost:3000
Content-Type: application/json
X-Auth-Token: <token>
X-User-Id: <user_id>

{
  "department": {
    "name": "Exploited Department",
    "email": "test@test.com",
    "enabled": true,
    "showOnRegistration": true,
    "showOnOfflineForm": true,
    "numAgents": 9999,
    "archived": true,
    "businessHourId": "unauthorized-business-hour-id"
  }
}

The numAgents, archived, and businessHourId fields will be successfully validated by saveDepartment (since they are Integer, Boolean, and String respectively) and persisted to the database via createOrUpdateDepartment.

View full scan results

Comment on lines +472 to +479
const displayName = this.getDisplayNameFromInvite(req);
const usernameFromHeader = req.has('X-RocketChat-Caller-Username') && req.get('X-RocketChat-Caller-Username');

const displayName = displayNameFromHeader || callerBase?.displayName || req.from;
const username = usernameFromHeader || callerBase?.username || req.callingNumber;

const sipExtension = req.callingNumber;

const defaultContactInfo: MediaCallContactInformation = {
username,
sipExtension,
displayName: displayName || sipExtension,
...(usernameFromHeader && { username: usernameFromHeader }),
Copy link
Copy Markdown

Choose a reason for hiding this comment

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

🟡 Medium: SIP Caller Identity Spoofing via Unverified Headers

The IncomingSipCall.getCallerContactFromInvite method trusts SIP headers (X-RocketChat-Caller-Name, X-RocketChat-Caller-Username, p-asserted-identity, from) to construct the caller's identity (MediaCallContactInformation). These headers are provided by the external SIP peer and are not cryptographically verified. An attacker can spoof the caller's display name and username, which are then used throughout the application to represent the caller, potentially leading to social engineering or impersonation attacks within the Rocket.Chat interface.

Steps to Reproduce
  1. Configure a SIP client to send an INVITE request to the Rocket.Chat SIP server.
  2. Add custom headers 'X-RocketChat-Caller-Name' and 'X-RocketChat-Caller-Username' to the INVITE request with arbitrary values (e.g., 'CEO', 'admin').
  3. Observe that the Rocket.Chat UI displays the caller as the spoofed identity.
# Not applicable for SIP. Use the bash script PoC.
# This is a conceptual PoC.
# An attacker sends a SIP INVITE with spoofed headers.
# The server will process these headers and display the spoofed identity to the callee.

cat <<EOF | nc <SIP_SERVER_IP> 5060
INVITE sip:target@example.com SIP/2.0
Via: SIP/2.0/UDP attacker.com;branch=z9hG4bK123
From: "Spoofed User" <sip:attacker@attacker.com>;tag=123
To: <sip:target@example.com>
Call-ID: 123@attacker.com
CSeq: 1 INVITE
X-RocketChat-Caller-Name: "CEO"
X-RocketChat-Caller-Username: "admin"
Content-Type: application/sdp
Content-Length: 0
EOF
# Not applicable for SIP. Use the bash script PoC.

PoC Url: N/A

Fix with AI

Open in Cursor Open in Claude

Fix the following security vulnerability found by Hacktron.

File: ee/packages/media-calls/src/sip/providers/IncomingSipCall.ts
Lines: 472-479
Severity: medium

Vulnerability: SIP Caller Identity Spoofing via Unverified Headers

Description:
The IncomingSipCall.getCallerContactFromInvite method trusts SIP headers (X-RocketChat-Caller-Name, X-RocketChat-Caller-Username, p-asserted-identity, from) to construct the caller's identity (MediaCallContactInformation). These headers are provided by the external SIP peer and are not cryptographically verified. An attacker can spoof the caller's display name and username, which are then used throughout the application to represent the caller, potentially leading to social engineering or impersonation attacks within the Rocket.Chat interface.

Proof of Concept:
**Steps to Reproduce**

1. Configure a SIP client to send an INVITE request to the Rocket.Chat SIP server.
2. Add custom headers 'X-RocketChat-Caller-Name' and 'X-RocketChat-Caller-Username' to the INVITE request with arbitrary values (e.g., 'CEO', 'admin').
3. Observe that the Rocket.Chat UI displays the caller as the spoofed identity.

```python
# Not applicable for SIP. Use the bash script PoC.
```

```bash
# This is a conceptual PoC.
# An attacker sends a SIP INVITE with spoofed headers.
# The server will process these headers and display the spoofed identity to the callee.

cat <<EOF | nc <SIP_SERVER_IP> 5060
INVITE sip:target@example.com SIP/2.0
Via: SIP/2.0/UDP attacker.com;branch=z9hG4bK123
From: "Spoofed User" <sip:attacker@attacker.com>;tag=123
To: <sip:target@example.com>
Call-ID: 123@attacker.com
CSeq: 1 INVITE
X-RocketChat-Caller-Name: "CEO"
X-RocketChat-Caller-Username: "admin"
Content-Type: application/sdp
Content-Length: 0
EOF
```

```bash
# Not applicable for SIP. Use the bash script PoC.
```


PoC Url: N/A

Affected Code:
const displayName = this.getDisplayNameFromInvite(req);
const usernameFromHeader = req.has('X-RocketChat-Caller-Username') && req.get('X-RocketChat-Caller-Username');
const sipExtension = req.callingNumber;

const defaultContactInfo: MediaCallContactInformation = {
    sipExtension,
    displayName: displayName || sipExtension,
    ...(usernameFromHeader && { username: usernameFromHeader }),
};

const contact = await mediaCallDirector.cast.getContactForExtensionNumber(sipExtension, { requiredType: 'sip' }, defaultContactInfo);

Fix this vulnerability. Only change what's necessary - don't modify unrelated code.

Triage: Reply !fp <reason> (false positive), !valid (confirmed), or !accepted_risk <reason>. Reason is optional but improves future scans — e.g. !fp internal endpoint, not user-facing. Any other reply is saved as a triage note.

View finding in Hacktron

@aleksandernsilva aleksandernsilva added this to the POC-VOICE milestone May 27, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

type: feature Pull requests that introduces new feature

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants