Skip to content

feat: allow clients to accept calls before the session is established#40141

Open
pierre-lehnen-rc wants to merge 22 commits intodevelopfrom
feat/accept-media-call-via-rest
Open

feat: allow clients to accept calls before the session is established#40141
pierre-lehnen-rc wants to merge 22 commits intodevelopfrom
feat/accept-media-call-via-rest

Conversation

@pierre-lehnen-rc
Copy link
Copy Markdown
Contributor

@pierre-lehnen-rc pierre-lehnen-rc commented Apr 13, 2026

Proposed changes (including videos or screenshots)

Currently the call can only be accepted from a websocket connection, but in order to implement mobile support the app needs to be able to accept the call from a push notification, before a websocket connection is established. This PR adds an endpoint for that.

Issue(s)

VMUX-35

Steps to test or reproduce

Further comments

Re-opening #38646 which was merged prematurely

Summary by CodeRabbit

  • New Features

    • New REST endpoint to accept/reject media calls when no active session exists.
    • Server-side support for answering calls and querying calls by callee.
  • Bug Fixes / Reliability

    • Improved validation, error handling and state checks for call answers.
    • Made signal processing asynchronous and added options to enforce strict handling.

@dionisio-bot
Copy link
Copy Markdown
Contributor

dionisio-bot bot commented Apr 13, 2026

Looks like this PR is ready to merge! 🎉
If you have any trouble, please check the PR guidelines

@changeset-bot
Copy link
Copy Markdown

changeset-bot bot commented Apr 13, 2026

🦋 Changeset detected

Latest commit: c8d2aa7

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

This PR includes changesets to release 42 packages
Name Type
@rocket.chat/media-calls Minor
@rocket.chat/core-services Minor
@rocket.chat/model-typings Minor
@rocket.chat/models Minor
@rocket.chat/meteor Minor
@rocket.chat/media-signaling Minor
@rocket.chat/account-service Patch
@rocket.chat/authorization-service Patch
@rocket.chat/ddp-streamer Patch
@rocket.chat/omnichannel-transcript Patch
@rocket.chat/presence-service Patch
@rocket.chat/queue-worker Patch
@rocket.chat/abac Patch
@rocket.chat/federation-matrix Patch
@rocket.chat/network-broker Patch
@rocket.chat/omni-core-ee Patch
@rocket.chat/omnichannel-services Patch
@rocket.chat/presence Patch
rocketchat-services Patch
@rocket.chat/apps Patch
@rocket.chat/cron Patch
@rocket.chat/instance-status Patch
@rocket.chat/omni-core Patch
@rocket.chat/server-fetch Patch
@rocket.chat/ui-client Major
@rocket.chat/ddp-client Patch
@rocket.chat/ui-voip Major
@rocket.chat/livechat Patch
@rocket.chat/mock-providers Patch
@rocket.chat/ui-contexts Major
@rocket.chat/uikit-playground Patch
@rocket.chat/fuselage-ui-kit Major
@rocket.chat/gazzodown Major
@rocket.chat/ui-avatar Major
@rocket.chat/ui-video-conf Major
@rocket.chat/web-ui-registration Major
@rocket.chat/core-typings Minor
@rocket.chat/rest-typings Minor
@rocket.chat/api-client Patch
@rocket.chat/http-router Patch
@rocket.chat/license Patch
@rocket.chat/pdf-worker Patch

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 Apr 13, 2026

No actionable comments were generated in the recent review. 🎉

ℹ️ Recent review info
⚙️ Run configuration

Configuration used: Organization UI

Review profile: CHILL

Plan: Pro

Run ID: d2416364-d8e9-47b7-a8fc-94fd022b014c

📥 Commits

Reviewing files that changed from the base of the PR and between 10fad95 and c8d2aa7.

📒 Files selected for processing (2)
  • ee/packages/media-calls/src/internal/SignalProcessor.ts
  • ee/packages/media-calls/src/internal/agents/UserActorAgent.ts
🚧 Files skipped from review as they are similar to previous changes (1)
  • ee/packages/media-calls/src/internal/SignalProcessor.ts
📜 Recent 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). (4)
  • GitHub Check: 📦 Build Packages
  • GitHub Check: cubic · AI code reviewer
  • 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/internal/agents/UserActorAgent.ts
🧠 Learnings (3)
📓 Common learnings
Learnt from: smirk-dev
Repo: RocketChat/Rocket.Chat PR: 39625
File: apps/meteor/app/api/server/v1/push.ts:85-97
Timestamp: 2026-03-14T14:58:58.834Z
Learning: In RocketChat/Rocket.Chat, the `push.token` POST/DELETE endpoints in `apps/meteor/app/api/server/v1/push.ts` were already migrated to the chained router API pattern on `develop` prior to PR `#39625`. `cleanTokenResult` (which strips `authToken` and returns `PushTokenResult`) and `isPushTokenPOSTProps`/`isPushTokenDELETEProps` validators already exist on `develop`. PR `#39625` only migrates `push.get` and `push.info` to the chained pattern. Do not flag `cleanTokenResult` or `PushTokenResult` as newly introduced behavior-breaking changes when reviewing this PR.
📚 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/internal/agents/UserActorAgent.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/internal/agents/UserActorAgent.ts
🔇 Additional comments (2)
ee/packages/media-calls/src/internal/agents/UserActorAgent.ts (2)

8-8: Type-only import is correctly introduced.

SignalProcessingOptions is imported as type, which keeps runtime output clean and matches its usage in the method signature.


16-20: Options passthrough is correctly wired and backward-compatible.

The optional options parameter is correctly forwarded to UserActorSignalProcessor.processSignal, preserving REST-driven throwIfSkipped behavior while keeping existing callers valid.


Walkthrough

Adds a new authenticated REST endpoint POST /media-calls.answer to accept/reject media calls without an active session, plus service, signal-processing, model, and type updates to propagate async handling and an option to throw when signals are skipped.

Changes

Cohort / File(s) Summary
Changeset / Release Notes
​.changeset/fair-lions-smell.md
New changeset declaring minor version bumps and documenting the new REST endpoint.
REST Endpoint & Request Validation
apps/meteor/app/api/server/v1/media-calls.ts
Added authenticated POST /media-calls.answer, AJV-compiled validator isMediaCallsAnswerProps, and route typing augmentation returning updated IMediaCall and success.
Service Layer
apps/meteor/server/services/media-call/service.ts, packages/core-services/src/types/IMediaCallService.ts
Added MediaCallService.answerCall(uid, params) and updated IMediaCallService with answerCall; service loads call by id/callee, sends a ClientMediaSignalAnswer to the signal pipeline with throw-on-skip, validates resulting state, and returns the updated call.
Signal Processing Contracts
ee/packages/media-calls/src/definition/common.ts, ee/packages/media-calls/src/definition/IMediaCallServer.ts
Introduced SignalProcessingOptions type ({ throwIfSkipped?: boolean }) and changed IMediaCallServer.receiveSignal to async and to accept options?: SignalProcessingOptions.
Signal Processor Core
ee/packages/media-calls/src/internal/SignalProcessor.ts, ee/packages/media-calls/src/server/MediaCallServer.ts
Propagated options through GlobalSignalProcessor and MediaCallServer; made processing async and conditionally throw invalid-contract when throwIfSkipped is set. Updated error handling and call to agent.processSignal to pass options.
Call Signal Agent / Processor
ee/packages/media-calls/src/internal/agents/CallSignalProcessor.ts, ee/packages/media-calls/src/internal/agents/UserActorAgent.ts
Extended agent and processor processSignal signatures to accept SignalProcessingOptions, added throwIfSkipped state, introduced validatePendingCallee() that may throw invalid-call-role/invalid-call-state when flagged.
Call Answer Types & Schema
packages/media-signaling/src/definition/call/IClientMediaCall.ts, packages/media-signaling/src/definition/signals/client/answer.ts
Replaced inline CallAnswer union with const-backed callAnswerList and updated the client answer schema to reference it for validation.
Data Access Layer
packages/model-typings/src/models/IMediaCallsModel.ts, packages/models/src/models/MediaCalls.ts
Added findOneByIdAndCallee(id, callee, options?) to model typings and implemented it in MediaCallsRaw to query by _id and callee { type,id,contractId? }.

Sequence Diagram(s)

sequenceDiagram
  participant Client
  participant REST as MediaCalls REST
  participant Service as MediaCallService
  participant SignalProc as GlobalSignalProcessor
  participant Agent as UserActorAgent
  participant DB as MediaCallsModel

  Client->>REST: POST /media-calls.answer (callId, contractId?, answer, supportedFeatures?)
  REST->>Service: answerCall(userId, params)
  Service->>DB: findOneByIdAndCallee(callId, callee)
  DB-->>Service: IMediaCall
  Service->>SignalProc: receiveSignal(userId, ClientMediaSignalAnswer, {throwIfSkipped: true})
  SignalProc->>Agent: processSignal(call, signal, {throwIfSkipped:true})
  Agent->>Agent: validatePendingCallee() (may throw)
  Agent-->>SignalProc: processing result
  SignalProc-->>Service: resolved
  Service->>DB: reload call (findOne)
  DB-->>Service: updated IMediaCall
  Service-->>REST: updated call
  REST-->>Client: 200 { success: true, call }
Loading

Estimated code review effort

🎯 4 (Complex) | ⏱️ ~60 minutes

Possibly related PRs

🚥 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 clearly describes the main feature: enabling clients to accept calls before session establishment, which aligns with the primary change of adding a REST endpoint for call acceptance.
Linked Issues check ✅ Passed The PR implements a REST endpoint for accepting calls (media-calls.answer) and supporting infrastructure, directly addressing the requirement in VMUX-35 for accept/reject endpoints via REST API.
Out of Scope Changes check ✅ Passed All changes are scoped to implementing the accept call REST endpoint and necessary supporting infrastructure; no unrelated modifications detected.
Docstring Coverage ✅ Passed No functions found in the changed files to evaluate docstring coverage. Skipping docstring coverage check.

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


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.

@codecov
Copy link
Copy Markdown

codecov bot commented Apr 13, 2026

Codecov Report

❌ Patch coverage is 0% with 27 lines in your changes missing coverage. Please review.
✅ Project coverage is 70.19%. Comparing base (5af6363) to head (c8d2aa7).
⚠️ Report is 5 commits behind head on develop.

Additional details and impacted files

Impacted file tree graph

@@             Coverage Diff             @@
##           develop   #40141      +/-   ##
===========================================
- Coverage    70.21%   70.19%   -0.02%     
===========================================
  Files         3280     3280              
  Lines       116814   116876      +62     
  Branches     20715    20730      +15     
===========================================
+ Hits         82021    82045      +24     
- Misses       31516    31544      +28     
- Partials      3277     3287      +10     
Flag Coverage Δ
e2e 59.70% <ø> (+<0.01%) ⬆️
e2e-api 46.42% <0.00%> (-0.13%) ⬇️
unit 71.05% <ø> (+<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.

Base automatically changed from feat/voip-rest-state to develop April 13, 2026 20:34
@scuciatto scuciatto added this to the 8.4.0 milestone Apr 14, 2026
@pierre-lehnen-rc pierre-lehnen-rc marked this pull request as ready for review April 14, 2026 14:15
@pierre-lehnen-rc pierre-lehnen-rc requested review from a team as code owners April 14, 2026 14:15
@coderabbitai coderabbitai bot added the type: feature Pull requests that introduces new feature label Apr 14, 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.

Actionable comments posted: 1

🧹 Nitpick comments (3)
packages/model-typings/src/models/IMediaCallsModel.ts (1)

14-18: Align options generic with the method’s generic return type.

findOneByIdAndCallee<T> currently returns T but accepts FindOptions<IMediaCall>, which weakens projection/type inference for T.

Proposed typing alignment (interface + implementation)
--- a/packages/model-typings/src/models/IMediaCallsModel.ts
+++ b/packages/model-typings/src/models/IMediaCallsModel.ts
@@
 	findOneByIdAndCallee<T extends Document = IMediaCall>(
 		id: IMediaCall['_id'],
 		callee: MediaCallActor,
-		options?: FindOptions<IMediaCall>,
+		options?: FindOptions<T>,
 	): Promise<T | null>;
--- a/packages/models/src/models/MediaCalls.ts
+++ b/packages/models/src/models/MediaCalls.ts
@@
 	public async findOneByIdAndCallee<T extends Document = IMediaCall>(
 		id: IMediaCall['_id'],
 		callee: MediaCallActor,
-		options?: FindOptions<IMediaCall>,
+		options?: FindOptions<T>,
 	): Promise<T | null> {
🤖 Prompt for AI Agents
Verify each finding against the current code and only fix it if needed.

In `@packages/model-typings/src/models/IMediaCallsModel.ts` around lines 14 - 18,
The method findOneByIdAndCallee<T extends Document = IMediaCall> accepts options
typed as FindOptions<IMediaCall>, which prevents callers from projecting to T;
change the options parameter to FindOptions<T> (and update the implementation of
findOneByIdAndCallee to accept and forward that generic options type) so the
method signature becomes findOneByIdAndCallee<T extends Document =
IMediaCall>(id: IMediaCall['_id'], callee: MediaCallActor, options?:
FindOptions<T>): Promise<T | null> and ensure any internal calls (e.g., to the
underlying repository/db helpers) also use the T-typed options to preserve
projection/type inference.
ee/packages/media-calls/src/definition/common.ts (1)

33-35: Remove inline implementation comments in the new options type.

Keep SignalProcessingOptions self-descriptive and move rationale to external docs/PR notes instead of code comments.

Proposed cleanup
 export type SignalProcessingOptions = {
-	// Some signals can be safely skipped when they are not relevant to the current call state, but
-	// if the signal was received via REST, we shouldn't return success without processing anything, so we throw an error instead
 	throwIfSkipped?: boolean;
 };

As per coding guidelines: **/*.{ts,tsx,js} → "Avoid code comments in the implementation".

🤖 Prompt for AI Agents
Verify each finding against the current code and only fix it if needed.

In `@ee/packages/media-calls/src/definition/common.ts` around lines 33 - 35,
Remove the inline implementation comment above the throwIfSkipped property in
the SignalProcessingOptions type so the type remains self-descriptive; leave the
throwIfSkipped?: boolean; declaration intact and move any rationale or details
into external docs/PR notes instead of in-code comments. Ensure no other
explanatory comments are added inside the type declaration
(SignalProcessingOptions) and keep the code clean and comment-free per the
coding guidelines.
packages/media-signaling/src/definition/call/IClientMediaCall.ts (1)

46-50: Drop inline comments from callAnswerList entries.

The values are already self-explanatory; remove implementation comments to keep the file aligned with repo style rules.

Proposed cleanup
 export const callAnswerList = [
-	'accept', // actor accepts the call
-	'reject', // actor rejects the call
-	'ack', // agent confirms the actor is reachable
-	'unavailable', // agent reports the actor is unavailable
+	'accept',
+	'reject',
+	'ack',
+	'unavailable',
 ] as const;

As per coding guidelines: **/*.{ts,tsx,js} → "Avoid code comments in the implementation".

🤖 Prompt for AI Agents
Verify each finding against the current code and only fix it if needed.

In `@packages/media-signaling/src/definition/call/IClientMediaCall.ts` around
lines 46 - 50, Remove the inline comments inside the callAnswerList array so
each entry is just the string literal (e.g., 'accept', 'reject', 'ack',
'unavailable') and keep the as const assertion; update the declaration named
callAnswerList in IClientMediaCall.ts to strip the trailing explanatory comments
after each value to conform with the repo coding guideline banning
implementation comments.
🤖 Prompt for all review comments with AI agents
Verify each finding against the current code and only fix it if needed.

Inline comments:
In `@ee/packages/media-calls/src/internal/SignalProcessor.ts`:
- Line 119: The throwIfSkipped option set in SignalProcessor is never forwarded
into the lower-level processors; update UserActorAgent.processSignal to accept
an options parameter (e.g., options: SignalProcessingOptions) and have it call
signalProcessor.processSignal(signal, options), then change the call site at
agent.processSignal(call, signal) to agent.processSignal(call, signal, options)
so throwIfSkipped is propagated to UserActorSignalProcessor.processSignal and
the invalid-call-role / invalid-call-state errors are correctly thrown.

---

Nitpick comments:
In `@ee/packages/media-calls/src/definition/common.ts`:
- Around line 33-35: Remove the inline implementation comment above the
throwIfSkipped property in the SignalProcessingOptions type so the type remains
self-descriptive; leave the throwIfSkipped?: boolean; declaration intact and
move any rationale or details into external docs/PR notes instead of in-code
comments. Ensure no other explanatory comments are added inside the type
declaration (SignalProcessingOptions) and keep the code clean and comment-free
per the coding guidelines.

In `@packages/media-signaling/src/definition/call/IClientMediaCall.ts`:
- Around line 46-50: Remove the inline comments inside the callAnswerList array
so each entry is just the string literal (e.g., 'accept', 'reject', 'ack',
'unavailable') and keep the as const assertion; update the declaration named
callAnswerList in IClientMediaCall.ts to strip the trailing explanatory comments
after each value to conform with the repo coding guideline banning
implementation comments.

In `@packages/model-typings/src/models/IMediaCallsModel.ts`:
- Around line 14-18: The method findOneByIdAndCallee<T extends Document =
IMediaCall> accepts options typed as FindOptions<IMediaCall>, which prevents
callers from projecting to T; change the options parameter to FindOptions<T>
(and update the implementation of findOneByIdAndCallee to accept and forward
that generic options type) so the method signature becomes
findOneByIdAndCallee<T extends Document = IMediaCall>(id: IMediaCall['_id'],
callee: MediaCallActor, options?: FindOptions<T>): Promise<T | null> and ensure
any internal calls (e.g., to the underlying repository/db helpers) also use the
T-typed options to preserve projection/type inference.
🪄 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: 03e4ca0b-b5fc-4708-974a-2d2a521f9583

📥 Commits

Reviewing files that changed from the base of the PR and between 5af6363 and 10fad95.

📒 Files selected for processing (13)
  • .changeset/fair-lions-smell.md
  • apps/meteor/app/api/server/v1/media-calls.ts
  • apps/meteor/server/services/media-call/service.ts
  • ee/packages/media-calls/src/definition/IMediaCallServer.ts
  • ee/packages/media-calls/src/definition/common.ts
  • ee/packages/media-calls/src/internal/SignalProcessor.ts
  • ee/packages/media-calls/src/internal/agents/CallSignalProcessor.ts
  • ee/packages/media-calls/src/server/MediaCallServer.ts
  • packages/core-services/src/types/IMediaCallService.ts
  • packages/media-signaling/src/definition/call/IClientMediaCall.ts
  • packages/media-signaling/src/definition/signals/client/answer.ts
  • packages/model-typings/src/models/IMediaCallsModel.ts
  • packages/models/src/models/MediaCalls.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). (15)
  • GitHub Check: cubic · AI code reviewer
  • GitHub Check: 🔨 Test UI (EE) / MongoDB 8.0 coverage (5/5)
  • GitHub Check: 🔨 Test UI (CE) / MongoDB 8.0 (1/4)
  • GitHub Check: 🔨 Test UI (EE) / MongoDB 8.0 coverage (4/5)
  • GitHub Check: 🔨 Test UI (CE) / MongoDB 8.0 (4/4)
  • GitHub Check: 🔨 Test UI (EE) / MongoDB 8.0 coverage (1/5)
  • GitHub Check: 🔨 Test UI (CE) / MongoDB 8.0 (2/4)
  • GitHub Check: 🔨 Test UI (CE) / MongoDB 8.0 (3/4)
  • GitHub Check: 🔨 Test API Livechat (EE) / MongoDB 8.0 coverage (1/1)
  • GitHub Check: 🔨 Test UI (EE) / MongoDB 8.0 coverage (2/5)
  • GitHub Check: 🔨 Test API (CE) / MongoDB 8.0 (1/1)
  • GitHub Check: 🔨 Test UI (EE) / MongoDB 8.0 coverage (3/5)
  • GitHub Check: 🔨 Test API Livechat (CE) / MongoDB 8.0 (1/1)
  • GitHub Check: 🔨 Test API (EE) / MongoDB 8.0 coverage (1/1)
  • GitHub Check: 🔨 Test Federation Matrix
🧰 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/definition/common.ts
  • packages/media-signaling/src/definition/signals/client/answer.ts
  • ee/packages/media-calls/src/definition/IMediaCallServer.ts
  • packages/core-services/src/types/IMediaCallService.ts
  • packages/models/src/models/MediaCalls.ts
  • packages/media-signaling/src/definition/call/IClientMediaCall.ts
  • packages/model-typings/src/models/IMediaCallsModel.ts
  • ee/packages/media-calls/src/server/MediaCallServer.ts
  • ee/packages/media-calls/src/internal/SignalProcessor.ts
  • apps/meteor/app/api/server/v1/media-calls.ts
  • apps/meteor/server/services/media-call/service.ts
  • ee/packages/media-calls/src/internal/agents/CallSignalProcessor.ts
🧠 Learnings (19)
📓 Common learnings
Learnt from: smirk-dev
Repo: RocketChat/Rocket.Chat PR: 39625
File: apps/meteor/app/api/server/v1/push.ts:85-97
Timestamp: 2026-03-14T14:58:58.834Z
Learning: In RocketChat/Rocket.Chat, the `push.token` POST/DELETE endpoints in `apps/meteor/app/api/server/v1/push.ts` were already migrated to the chained router API pattern on `develop` prior to PR `#39625`. `cleanTokenResult` (which strips `authToken` and returns `PushTokenResult`) and `isPushTokenPOSTProps`/`isPushTokenDELETEProps` validators already exist on `develop`. PR `#39625` only migrates `push.get` and `push.info` to the chained pattern. Do not flag `cleanTokenResult` or `PushTokenResult` as newly introduced behavior-breaking changes when reviewing this PR.
📚 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
  • packages/media-signaling/src/definition/signals/client/answer.ts
  • ee/packages/media-calls/src/definition/IMediaCallServer.ts
  • packages/core-services/src/types/IMediaCallService.ts
  • packages/models/src/models/MediaCalls.ts
  • packages/media-signaling/src/definition/call/IClientMediaCall.ts
  • packages/model-typings/src/models/IMediaCallsModel.ts
  • ee/packages/media-calls/src/server/MediaCallServer.ts
  • ee/packages/media-calls/src/internal/SignalProcessor.ts
  • apps/meteor/app/api/server/v1/media-calls.ts
  • apps/meteor/server/services/media-call/service.ts
  • ee/packages/media-calls/src/internal/agents/CallSignalProcessor.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
  • packages/media-signaling/src/definition/signals/client/answer.ts
  • ee/packages/media-calls/src/definition/IMediaCallServer.ts
  • packages/core-services/src/types/IMediaCallService.ts
  • packages/models/src/models/MediaCalls.ts
  • packages/media-signaling/src/definition/call/IClientMediaCall.ts
  • packages/model-typings/src/models/IMediaCallsModel.ts
  • ee/packages/media-calls/src/server/MediaCallServer.ts
  • ee/packages/media-calls/src/internal/SignalProcessor.ts
  • apps/meteor/app/api/server/v1/media-calls.ts
  • apps/meteor/server/services/media-call/service.ts
  • ee/packages/media-calls/src/internal/agents/CallSignalProcessor.ts
📚 Learning: 2025-12-18T15:18:31.688Z
Learnt from: gabriellsh
Repo: RocketChat/Rocket.Chat PR: 37773
File: apps/meteor/client/views/mediaCallHistory/MediaCallHistoryInternal.tsx:24-34
Timestamp: 2025-12-18T15:18:31.688Z
Learning: In apps/meteor/client/views/mediaCallHistory/MediaCallHistoryInternal.tsx, for internal call history items, the item.contactId is guaranteed to always match either the caller.id or callee.id in the call data, so the contact resolution in getContact will never result in undefined.

Applied to files:

  • ee/packages/media-calls/src/definition/IMediaCallServer.ts
  • packages/core-services/src/types/IMediaCallService.ts
  • packages/models/src/models/MediaCalls.ts
  • packages/model-typings/src/models/IMediaCallsModel.ts
  • ee/packages/media-calls/src/internal/SignalProcessor.ts
  • apps/meteor/server/services/media-call/service.ts
📚 Learning: 2025-11-19T18:20:37.116Z
Learnt from: gabriellsh
Repo: RocketChat/Rocket.Chat PR: 37419
File: apps/meteor/server/services/media-call/service.ts:141-141
Timestamp: 2025-11-19T18:20:37.116Z
Learning: In apps/meteor/server/services/media-call/service.ts, the sendHistoryMessage method should use call.caller.id or call.createdBy?.id as the message author, not call.transferredBy?.id. Even for transferred calls, the message should appear in the DM between the two users who are calling each other, not sent by the person who transferred the call.

Applied to files:

  • ee/packages/media-calls/src/definition/IMediaCallServer.ts
  • packages/core-services/src/types/IMediaCallService.ts
  • packages/models/src/models/MediaCalls.ts
  • packages/model-typings/src/models/IMediaCallsModel.ts
  • apps/meteor/app/api/server/v1/media-calls.ts
  • apps/meteor/server/services/media-call/service.ts
📚 Learning: 2026-03-16T21:50:42.118Z
Learnt from: amitb0ra
Repo: RocketChat/Rocket.Chat PR: 39676
File: .changeset/migrate-users-register-openapi.md:3-3
Timestamp: 2026-03-16T21:50:42.118Z
Learning: In RocketChat/Rocket.Chat OpenAPI migration PRs, removing endpoint types and validators from `rocket.chat/rest-typings` (e.g., `UserRegisterParamsPOST`, `/v1/users.register` entry) is the *required* migration pattern per RocketChat/Rocket.Chat-Open-API#150 Rule 7 ("No More rest-typings or Manual Typings"). The endpoint type is re-exposed via a module augmentation `.d.ts` file in the consuming package (e.g., `packages/web-ui-registration/src/users-register.d.ts`). This is NOT a breaking change — the correct changeset bump for `rocket.chat/rest-typings` in this scenario is `minor`, not `major`. Do not flag this as a breaking change during OpenAPI migration reviews.

Applied to files:

  • apps/meteor/app/api/server/v1/media-calls.ts
📚 Learning: 2026-03-12T10:26:26.697Z
Learnt from: ahmed-n-abdeltwab
Repo: RocketChat/Rocket.Chat PR: 39340
File: apps/meteor/app/api/server/v1/im.ts:1349-1398
Timestamp: 2026-03-12T10:26:26.697Z
Learning: In `apps/meteor/app/api/server/v1/im.ts` (PR `#39340`), the `DmEndpoints` type intentionally includes temporary stub entries for `/v1/im.kick`, `/v1/dm.kick`, `/v1/im.leave`, and `/v1/dm.leave` (using `DmKickProps` and `DmLeaveProps`) even though no route handlers exist for them yet. These stubs were added to preserve type compatibility after removing the original `DmLeaveProps` and related files. They are planned for cleanup in a follow-up PR. Do not flag these as missing implementations when reviewing this file until the follow-up is merged.

Applied to files:

  • apps/meteor/app/api/server/v1/media-calls.ts
📚 Learning: 2026-03-15T14:31:28.969Z
Learnt from: amitb0ra
Repo: RocketChat/Rocket.Chat PR: 39647
File: apps/meteor/app/api/server/v1/users.ts:710-757
Timestamp: 2026-03-15T14:31:28.969Z
Learning: In RocketChat/Rocket.Chat, the `UserCreateParamsPOST` type in `apps/meteor/app/api/server/v1/users.ts` (migrated from `packages/rest-typings/src/v1/users/UserCreateParamsPOST.ts`) intentionally has `fields: string` (non-optional) and `settings?: IUserSettings` without a corresponding AJV schema entry. This is a pre-existing divergence carried over verbatim from the original rest-typings source (PR `#39647`). Do not flag this type/schema misalignment during the OpenAPI migration review — it is tracked as a separate follow-up fix.

Applied to files:

  • apps/meteor/app/api/server/v1/media-calls.ts
📚 Learning: 2026-03-14T14:58:58.834Z
Learnt from: smirk-dev
Repo: RocketChat/Rocket.Chat PR: 39625
File: apps/meteor/app/api/server/v1/push.ts:85-97
Timestamp: 2026-03-14T14:58:58.834Z
Learning: In RocketChat/Rocket.Chat, the `push.token` POST/DELETE endpoints in `apps/meteor/app/api/server/v1/push.ts` were already migrated to the chained router API pattern on `develop` prior to PR `#39625`. `cleanTokenResult` (which strips `authToken` and returns `PushTokenResult`) and `isPushTokenPOSTProps`/`isPushTokenDELETEProps` validators already exist on `develop`. PR `#39625` only migrates `push.get` and `push.info` to the chained pattern. Do not flag `cleanTokenResult` or `PushTokenResult` as newly introduced behavior-breaking changes when reviewing this PR.

Applied to files:

  • apps/meteor/app/api/server/v1/media-calls.ts
  • .changeset/fair-lions-smell.md
📚 Learning: 2026-03-20T13:52:29.575Z
Learnt from: ggazzo
Repo: RocketChat/Rocket.Chat PR: 39553
File: apps/meteor/app/api/server/v1/stats.ts:98-117
Timestamp: 2026-03-20T13:52:29.575Z
Learning: In `apps/meteor/app/api/server/v1/stats.ts`, the `statistics.telemetry` POST endpoint intentionally has no `body` AJV schema in its route options. The proper request body shape (a `params` array of telemetry event objects) has not been formally defined yet, so body validation is deferred to a follow-up. Do not flag the missing body schema for this endpoint during OpenAPI migration reviews.

Applied to files:

  • apps/meteor/app/api/server/v1/media-calls.ts
📚 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/media-calls.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/media-calls.ts
📚 Learning: 2025-11-19T18:20:07.720Z
Learnt from: gabriellsh
Repo: RocketChat/Rocket.Chat PR: 37419
File: packages/i18n/src/locales/en.i18n.json:918-921
Timestamp: 2025-11-19T18:20:07.720Z
Learning: Repo: RocketChat/Rocket.Chat — i18n/formatting
Learning: This repository uses a custom message formatting parser in UI blocks/messages; do not assume standard Markdown rules. For keys like Call_ended_bold, Call_not_answered_bold, Call_failed_bold, and Call_transferred_bold in packages/i18n/src/locales/en.i18n.json, retain the existing single-asterisk emphasis unless maintainers request otherwise.

Applied to files:

  • apps/meteor/server/services/media-call/service.ts
  • .changeset/fair-lions-smell.md
📚 Learning: 2026-02-25T20:10:16.987Z
Learnt from: ahmed-n-abdeltwab
Repo: RocketChat/Rocket.Chat PR: 38913
File: packages/ddp-client/src/legacy/types/SDKLegacy.ts:34-34
Timestamp: 2026-02-25T20:10:16.987Z
Learning: In the RocketChat/Rocket.Chat monorepo, packages/ddp-client and apps/meteor do not use TypeScript project references. Module augmentations in apps/meteor (e.g., declare module 'rocket.chat/rest-typings') are not visible when compiling packages/ddp-client in isolation, which is why legacy SDK methods that depend on OperationResult types for OpenAPI-migrated endpoints must remain commented out.

Applied to files:

  • apps/meteor/server/services/media-call/service.ts
📚 Learning: 2026-02-26T19:22:36.646Z
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:36.646Z
Learning: In packages/ui-voip/src/views/CallHistoryContextualbar/CallHistoryActions.tsx, when the media session state is 'unavailable', the voiceCall action is not included in the actions object passed to CallHistoryActions, so it won't appear in the menu at all. The action filtering happens upstream before getItems is called, preventing any tooltip confusion for the unavailable state.

Applied to files:

  • ee/packages/media-calls/src/internal/agents/CallSignalProcessor.ts
📚 Learning: 2026-03-26T16:42:35.978Z
Learnt from: pierre-lehnen-rc
Repo: RocketChat/Rocket.Chat PR: 39870
File: packages/ui-voip/src/providers/useScreenShareStreams.ts:13-21
Timestamp: 2026-03-26T16:42:35.978Z
Learning: In `packages/ui-voip/src/providers/useScreenShareStreams.ts` (RocketChat/Rocket.Chat), the early return on `!instanceState.confirmed` in `getStreamWrappers` is intentional design: screen-share streams (both local and remote) are not used during unconfirmed/pending calls, so returning `null` for the whole unconfirmed state is correct. Do not suggest splitting the guard to expose the local participant stream before call confirmation.

Applied to files:

  • ee/packages/media-calls/src/internal/agents/CallSignalProcessor.ts
📚 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/fair-lions-smell.md
📚 Learning: 2026-02-24T19:09:09.561Z
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:09.561Z
Learning: In RocketChat/Rocket.Chat OpenAPI migration PRs for apps/meteor/app/api/server/v1 endpoints, maintainers prefer to avoid any logic changes; style-only cleanups (like removing inline comments) may be deferred to follow-ups to keep scope tight.

Applied to files:

  • .changeset/fair-lions-smell.md
📚 Learning: 2026-02-24T19:05:56.710Z
Learnt from: ahmed-n-abdeltwab
Repo: RocketChat/Rocket.Chat PR: 0
File: :0-0
Timestamp: 2026-02-24T19:05:56.710Z
Learning: Rocket.Chat repo context: When a workspace manifest on develop already pins a dependency version (e.g., packages/web-ui-registration → "rocket.chat/ui-contexts": "27.0.1"), a lockfile change in a feature PR that upgrades only that dependency’s resolution is considered a manifest-driven sync and can be kept, preferably as a small "chore: sync yarn.lock with manifests" commit.

Applied to files:

  • .changeset/fair-lions-smell.md
🔇 Additional comments (12)
.changeset/fair-lions-smell.md (1)

2-10: Changeset scope and bump level look good.

Minor bumps and release-note scope are consistent with the additive REST call-answer capability.

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

45-45: Interface update is coherent with async signal processing.

The added options parameter and async return type align with the server implementation and REST-driven signaling flow.

packages/media-signaling/src/definition/signals/client/answer.ts (1)

4-4: Good consolidation of answer enum source.

Using callAnswerList for schema validation keeps runtime and type-level allowed values synchronized.

Also applies to: 36-36

packages/core-services/src/types/IMediaCallService.ts (1)

5-5: Service contract addition looks well-typed.

answerCall cleanly exposes the new flow while preventing callers from overriding the signal type.

packages/models/src/models/MediaCalls.ts (1)

41-55: Callee-scoped lookup is a solid guardrail.

The _id + callee identity filter is appropriate for preventing unrelated users from answering a call by id alone.

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

50-52: LGTM - Clean delegation pattern.

The refactored receiveSignal properly delegates validation and processing to SignalProcessor, passing through the optional SignalProcessingOptions. This aligns with the async flow needed for the new REST endpoint.

apps/meteor/app/api/server/v1/media-calls.ts (1)

55-92: LGTM - Well-structured REST endpoint.

The endpoint correctly validates the request body using AJV with the shared callAnswerList and callFeatureList enums, ensuring type-safe validation that stays in sync with the media-signaling definitions.

ee/packages/media-calls/src/internal/SignalProcessor.ts (1)

97-100: LGTM - Conditional error throwing for contract mismatch.

The throwIfSkipped check correctly enables the REST flow to receive actionable errors (invalid-contract) instead of silent returns, while preserving the existing behavior for WebSocket-based signal processing.

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

50-96: Good defensive validation pattern for REST-based call answering.

The method correctly:

  1. Validates the caller is the callee before processing
  2. Uses throwIfSkipped: true to surface errors from signal processing
  3. Re-validates the call state after signal processing to ensure consistency

The reload-and-validate pattern at lines 69-93 provides an additional safety net against race conditions where another signal could modify the call between processing and response.


74-93: Add handling for 'unavailable' answer type in switch statement.

The switch statement at lines 74-93 includes explicit validation cases for 'ack', 'reject', and 'accept', but 'unavailable' (which is a valid CallAnswer type) falls through without a case. If no post-signal validation is needed for 'unavailable', add an explicit case to clarify intent; otherwise, add appropriate state validation matching the pattern used for other answer types.

ee/packages/media-calls/src/internal/agents/CallSignalProcessor.ts (2)

89-100: Well-designed optional error throwing for REST compatibility.

The pattern of accepting options with a default empty object and setting this.throwIfSkipped allows backward compatibility with WebSocket flows (silent returns) while enabling explicit error throwing for REST flows.

Note: This requires upstream callers (via UserActorAgent) to pass the options through for the REST flow to work as intended. See the related comment on SignalProcessor.ts line 119.


349-365: LGTM - Clean validation extraction.

The validatePendingCallee method properly centralizes the role and state checks for callee-only operations (accept, reject), with conditional error throwing based on throwIfSkipped. This reduces duplication in clientHasRejected and clientHasAccepted.

Copy link
Copy Markdown
Contributor

@cubic-dev-ai cubic-dev-ai bot left a comment

Choose a reason for hiding this comment

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

1 issue found across 13 files

Prompt for AI agents (unresolved issues)

Check if these issues are valid — if so, understand the root cause of each and fix them. If appropriate, use sub-agents to investigate and fix each issue separately.


<file name="packages/model-typings/src/models/IMediaCallsModel.ts">

<violation number="1" location="packages/model-typings/src/models/IMediaCallsModel.ts:17">
P2: The `options` parameter should use the generic type `T` (`FindOptions<T>`) instead of `IMediaCall` to correctly type the projection and return value.</violation>
</file>

Reply with feedback, questions, or to request a fix. Tag @cubic-dev-ai to re-run a review.

@pierre-lehnen-rc pierre-lehnen-rc added the stat: QA assured Means it has been tested and approved by a company insider label Apr 14, 2026
@dionisio-bot dionisio-bot bot added the stat: ready to merge PR tested and approved waiting for merge label Apr 14, 2026
});
}

this.throwIfSkipped = options.throwIfSkipped || false;
Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

it is not smart changing the state value of throwIfSkipped on every processSignal call, this could in theory affect async calls after multiple calls to processSignal.

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

Labels

stat: QA assured Means it has been tested and approved by a company insider stat: ready to merge PR tested and approved waiting for merge type: feature Pull requests that introduces new feature

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants