feat: Add support for call diversion handling in media calls#40560
feat: Add support for call diversion handling in media calls#40560aleksandernsilva wants to merge 3 commits into
Conversation
|
Looks like this PR is not ready to merge, because of the following issues:
Please fix the issues and try again If you have any trouble, please check the PR guidelines |
🦋 Changeset detectedLatest commit: f713a65 The changes in this PR will be included in the next version bump. This PR includes changesets to release 42 packages
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 |
|
Important Review skippedDraft detected. Please check the settings in the CodeRabbit UI or the ⚙️ Run configurationConfiguration used: Organization UI Review profile: CHILL Plan: Pro Run ID: You can disable this status message by setting the Use the checkbox below for a quick retry:
WalkthroughThis PR adds SIP Diversion header support to track call diversions in the media-calls system. A new data field ChangesCall Diversion Handling in Voice Calls
Estimated code review effort🎯 3 (Moderate) | ⏱️ ~20 minutes Suggested labels
🚥 Pre-merge checks | ✅ 5✅ Passed checks (5 passed)
✏️ Tip: You can configure your own custom pre-merge checks in the settings. Warning Review ran into problems🔥 ProblemsErrors were encountered while retrieving linked issues. Errors (1)
Tip 💬 Introducing Slack Agent: The best way for teams to turn conversations into code.Slack Agent is built on CodeRabbit's deep understanding of your code, so your team can collaborate across the entire SDLC without losing context.
Built for teams:
One agent for your entire SDLC. Right inside Slack. 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 |
Updates versioning for core-typings and media-calls to minor. Adds support for call diversion handling in voice calls.
|
@coderabbitai review |
✅ Actions performedReview triggered.
|
There was a problem hiding this comment.
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 `@packages/core-typings/src/mediaCalls/IMediaCall.ts`:
- Around line 67-68: The JSDoc for the divertedBy property claims the contact is
"signed with the session contract" but the type is MediaCallContact (which lacks
contractId) and IncomingSipCall.getDiversionContactFromInvite returns an
unsigned contact; update the comment on divertedBy to reflect that it may be
unsigned (i.e., remove or rephrase "signed with the session contract") or
explicitly state it can be either signed or unsigned, and if you intend it to
always be signed change the type to MediaCallSignedContact and update
IncomingSipCall.getDiversionContactFromInvite to populate contractId
accordingly; reference divertedBy, MediaCallContact, MediaCallSignedContact, and
IncomingSipCall.getDiversionContactFromInvite when making the change.
🪄 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: 388a87f0-efb0-4e50-a2f0-1e73667650c6
📒 Files selected for processing (7)
.changeset/gold-jobs-help.mdee/packages/media-calls/src/definition/common.tsee/packages/media-calls/src/server/CallDirector.tsee/packages/media-calls/src/server/signals/getNewCallTransferredBy.tsee/packages/media-calls/src/sip/providers/IncomingSipCall.tsee/packages/media-calls/src/sip/utils/parseDiversionHeader.tspackages/core-typings/src/mediaCalls/IMediaCall.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/signals/getNewCallTransferredBy.tspackages/core-typings/src/mediaCalls/IMediaCall.tsee/packages/media-calls/src/sip/utils/parseDiversionHeader.tsee/packages/media-calls/src/server/CallDirector.tsee/packages/media-calls/src/definition/common.tsee/packages/media-calls/src/sip/providers/IncomingSipCall.ts
🧠 Learnings (4)
📚 Learning: 2026-03-16T21:50:37.589Z
Learnt from: amitb0ra
Repo: RocketChat/Rocket.Chat PR: 39676
File: .changeset/migrate-users-register-openapi.md:3-3
Timestamp: 2026-03-16T21:50:37.589Z
Learning: For changes related to OpenAPI migrations in Rocket.Chat/OpenAPI, when removing endpoint types and validators from rocket.chat/rest-typings (e.g., UserRegisterParamsPOST, /v1/users.register) document this as a minor changeset (not breaking) per RocketChat/Rocket.Chat-Open-API#150 Rule 7. Note that the endpoint type is re-exposed via a module augmentation .d.ts in the consuming package (e.g., packages/web-ui-registration/src/users-register.d.ts). In reviews, ensure the changeset clearly states: this is a non-breaking change, the major version should not be bumped, and the changeset reflects a minor version bump. Do not treat this as a breaking change during OpenAPI migrations.
Applied to files:
.changeset/gold-jobs-help.md
📚 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/signals/getNewCallTransferredBy.tspackages/core-typings/src/mediaCalls/IMediaCall.tsee/packages/media-calls/src/sip/utils/parseDiversionHeader.tsee/packages/media-calls/src/server/CallDirector.tsee/packages/media-calls/src/definition/common.tsee/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/signals/getNewCallTransferredBy.tspackages/core-typings/src/mediaCalls/IMediaCall.tsee/packages/media-calls/src/sip/utils/parseDiversionHeader.tsee/packages/media-calls/src/server/CallDirector.tsee/packages/media-calls/src/definition/common.tsee/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/signals/getNewCallTransferredBy.tspackages/core-typings/src/mediaCalls/IMediaCall.tsee/packages/media-calls/src/sip/utils/parseDiversionHeader.tsee/packages/media-calls/src/server/CallDirector.tsee/packages/media-calls/src/definition/common.tsee/packages/media-calls/src/sip/providers/IncomingSipCall.ts
🔇 Additional comments (9)
.changeset/gold-jobs-help.md (1)
1-6: LGTM!ee/packages/media-calls/src/definition/common.ts (1)
19-19: LGTM!ee/packages/media-calls/src/sip/utils/parseDiversionHeader.ts (1)
1-47: LGTM!ee/packages/media-calls/src/sip/providers/IncomingSipCall.ts (3)
21-21: LGTM!Also applies to: 87-91
115-115: LGTM!
467-495: LGTM!ee/packages/media-calls/src/server/CallDirector.ts (2)
185-186: LGTM!
235-235: LGTM!ee/packages/media-calls/src/server/signals/getNewCallTransferredBy.ts (1)
5-9: LGTM!
Codecov Report✅ All modified and coverable lines are covered by tests. Additional details and impacted files@@ Coverage Diff @@
## develop #40560 +/- ##
===========================================
+ Coverage 69.61% 69.66% +0.04%
===========================================
Files 3325 3325
Lines 122797 122797
Branches 21831 21865 +34
===========================================
+ Hits 85490 85548 +58
+ Misses 33957 33915 -42
+ Partials 3350 3334 -16
Flags with carried forward coverage won't be shown. Click here to find out more. 🚀 New features to boost your workflow:
|
Removed reference to session contract from divertedBy comment.
Proposed changes (including videos or screenshots)
This pull request adds support for handling SIP call diversion by introducing a new
divertedByfield to the media calls system. The changes allow the system to detect when an incoming SIP call has been diverted, extract the relevant contact from the SIP Diversion header, and propagate this information through the media call creation and handling process.SIP Diversion Support:
divertedByfield to theIMediaCalltype and related internal call parameter types to represent the contact whose line was diverted at the SIP level.SIP Call Handling Improvements:
IncomingSipCallto detect and parse the SIP Diversion header from incoming calls, extract the diverting contact, and include it when creating new calls.parseDiversionHeaderto parse the Diversion header and extract the extension and display name.Call Transfer Logic:
getNewCallTransferredByto return thedivertedBycontact when available, ensuring accurate reporting of call transfers caused by SIP diversion.For the UI this change is transparent and incoming diverted calls will be treated as incoming call transfers.
Issue(s)
DMV-5
Steps to test or reproduce
If you are running freeswitch in a local container you can execute the following command to test
fs_cli -x "originate {sip_h_Diversion='\"John Doe\" <sip:sipp@[freeswitch_adress]>;reason=follow-me;privacy=off'}sofia/internal/[target_extension]@[sip_server_adress] &echo()"Further comments
Summary by CodeRabbit