Skip to content

Conversation

@OtavioStasiak
Copy link
Contributor

@OtavioStasiak OtavioStasiak commented Dec 15, 2025

Proposed changes

Remove deprecated methods based on https://docs.rocket.chat/docs/deprecated-and-phasing-out-features.

New endpoints
livechat/inquiries.take
livechat/inquiries.returnAsInquiry
livechat/config/routing
rooms.muteUser
rooms.unmuteUser

Deprecated methods
livechat:takeInquiry
livechat:returnAsInquiry
livechat:getRoutingConfig
muteUserInRoom
unmuteUserInRoom

Issue(s)

https://rocketchat.atlassian.net/browse/CORE-1560

How to test or reproduce

  • Open the app;
  • Go to a room;
  • Mute User;
  • Unmute user;
  • Go to omnichannel and take a omnichannel chat;
  • Return to waiting line;

Screenshots

Types of changes

  • Bugfix (non-breaking change which fixes an issue)
  • Improvement (non-breaking change which improves a current function)
  • New feature (non-breaking change which adds functionality)
  • Documentation update (if none of the other choices apply)

Checklist

  • I have read the CONTRIBUTING doc
  • I have signed the CLA
  • Lint and unit tests pass locally with my changes
  • I have added tests that prove my fix is effective or that my feature works (if applicable)
  • I have added necessary documentation (if applicable)
  • Any dependent changes have been merged and published in downstream modules

Further comments

Summary by CodeRabbit

  • New Features

    • Added omnichannel routing config endpoint to fetch live chat settings.
    • Added live chat inquiry endpoints to take inquiries and to return inquiries (optionally by department).
    • Added room mute and unmute endpoints to manage user mute state.
  • Improvements

    • Client detects server version and routes calls to the appropriate live chat and mute APIs for compatibility.
    • UI now forwards department and server-version context where applicable.

✏️ Tip: You can customize this high-level summary in your review settings.

@coderabbitai
Copy link
Contributor

coderabbitai bot commented Dec 15, 2025

Walkthrough

Adds new Omnichannel and Rooms REST endpoints and updates service and EE/UI call sites to use them with server-version guards; several functions gain extra parameters (serverVersion, departmentId, userId) and branch between new REST calls and legacy method wrappers.

Changes

Cohort / File(s) Summary
REST endpoint definitions
app/definitions/rest/v1/omnichannel.ts, app/definitions/rest/v1/rooms.ts
Add livechat/config/routing (GET), livechat/inquiries.take (POST), livechat/inquiries.returnAsInquiry (POST), and rooms.muteUser / rooms.unmuteUser (POST) to public REST definitions.
Service layer
app/lib/services/restApi.ts
Update signatures and branching: returnLivechat(rid, departmentId?); getRoutingConfig() → async and attempts livechat/config/routing; toggleMuteUserInRoom(rid, username, userId, mute) — use new REST endpoints when serverVersion meets thresholds, otherwise fall back to legacy methodCallWrapper.
EE omnichannel logic
app/ee/omnichannel/lib/index.ts
takeInquiry(inquiryId, serverVersion) updated to call sdk.post('livechat/inquiries.take', { inquiryId }) for newer servers or fallback to sdk.methodCallWrapper('livechat:takeInquiry', ...) for older servers.
UI / Call-site updates
app/views/RoomActionsView/index.tsx, app/views/RoomMembersView/helpers.ts, app/views/RoomView/RightButtons.tsx, app/views/RoomView/index.tsx
Propagate new parameters: pass departmentId to returnLivechat, pass userId to toggleMuteUserInRoom, and pass serverVersion to takeInquiry. Minor error handling remains unchanged.

Sequence Diagram(s)

sequenceDiagram
  participant UI as UI Component
  participant Service as restApi.ts
  participant EE as EE helper (omnichannel lib)
  participant ServerREST as Server (REST)
  participant ServerLegacy as Server (legacy RPC)

  UI->>Service: call returnLivechat(rid, departmentId?) / toggleMuteUserInRoom(...) / getRoutingConfig()
  alt calling takeInquiry flow
    UI->>EE: takeInquiry(inquiryId, serverVersion)
    EE->>Service: delegate to REST or legacy based on serverVersion
  end
  alt serverVersion >= threshold
    Service->>ServerREST: POST /livechat/inquiries.take or /livechat/inquiries.returnAsInquiry or /rooms.muteUser
    ServerREST-->>Service: HTTP response
  else older server
    Service->>ServerLegacy: sdk.methodCallWrapper(...) (legacy RPC)
    ServerLegacy-->>Service: RPC response
  end
  Service-->>UI: resolved result or error
Loading

Estimated code review effort

🎯 4 (Complex) | ⏱️ ~45 minutes

  • Inspect server-version comparison logic and thresholds in app/lib/services/restApi.ts and app/ee/omnichannel/lib/index.ts.
  • Verify consistency of parameter names between endpoint definitions and call sites (roomId vs rid) and optional departmentId.
  • Confirm updated call-sites pass correct types for serverVersion, departmentId, and userId.
  • Check return types and error handling compatibility for callers.

Suggested reviewers

  • diegolmello

Poem

🐇 I hopped through routes and patched a few,
New endpoints planted, old paths peek through,
I nudged a param here, a guard placed there,
Backward-safe bridges — tiny rabbit care,
Code carrots for all, and a quiet cheer.

Pre-merge checks and finishing touches

❌ Failed checks (3 warnings)
Check name Status Explanation Resolution
Title check ⚠️ Warning The title 'chore: remove deprecated methods for 8.0' is vague and misleading. The changes actually add new endpoints and implement version-conditional logic, not remove deprecated methods. Revise the title to accurately reflect the main changes, such as 'feat: add omnichannel and rooms endpoints with version-based fallback support' or similar.
Linked Issues check ⚠️ Warning The PR claims to remove deprecated endpoints per CORE-1560, but the changes show additions of new endpoints and version-conditional logic that maintains backward compatibility with older server versions. Clarify whether the PR removes deprecated code or adds new endpoints with fallback support. Update the implementation to align with the stated objective of removing deprecated endpoints for 8.0.
Out of Scope Changes check ⚠️ Warning The changes introduce new REST API endpoints and version-conditional fallback logic that go beyond the stated objective of removing deprecated endpoints for version 8.0. Define the scope clearly: determine if the objective is to remove deprecated code or add new endpoints. Remove any changes that don't align with the primary objective.
✅ Passed checks (2 passed)
Check name Status Explanation
Docstring Coverage ✅ Passed No functions found in the changed files to evaluate docstring coverage. Skipping docstring coverage check.
Description Check ✅ Passed Check skipped - CodeRabbit’s high-level summary is enabled.
✨ Finishing touches
  • 📝 Generate docstrings
🧪 Generate unit tests (beta)
  • Create PR with unit tests
  • Post copyable unit tests in a comment
  • Commit unit tests in branch chore.remove-deprecated-methods-8.0

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.

Copy link
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: 2

🧹 Nitpick comments (1)
app/views/RoomView/index.tsx (1)

1087-1110: Consider adding a null check for serverVersion.

The serverVersion prop can be null (as seen from state.server.version), but line 1095 casts it with as string. While compareServerVersion handles null values gracefully (returning false), the type assertion masks this possibility.

Consider a defensive check:

 if (this.isOmnichannel) {
   if ('_id' in room) {
-    await takeInquiry(room._id, serverVersion as string);
+    if (serverVersion) {
+      await takeInquiry(room._id, serverVersion);
+    }
   }
   this.onJoin();
 }

Alternatively, update the takeInquiry signature to explicitly accept string | null if the fallback behavior is intended.

📜 Review details

Configuration used: CodeRabbit UI

Review profile: CHILL

Plan: Pro

Disabled knowledge base sources:

  • Jira integration is disabled by default for public repositories

You can enable these sources in your CodeRabbit configuration.

📥 Commits

Reviewing files that changed from the base of the PR and between 7215cda and c7a8672.

📒 Files selected for processing (8)
  • app/definitions/rest/v1/omnichannel.ts (2 hunks)
  • app/definitions/rest/v1/rooms.ts (1 hunks)
  • app/ee/omnichannel/lib/index.ts (1 hunks)
  • app/lib/services/restApi.ts (3 hunks)
  • app/views/RoomActionsView/index.tsx (1 hunks)
  • app/views/RoomMembersView/helpers.ts (1 hunks)
  • app/views/RoomView/RightButtons.tsx (1 hunks)
  • app/views/RoomView/index.tsx (1 hunks)
🧰 Additional context used
🧬 Code graph analysis (4)
app/views/RoomActionsView/index.tsx (2)
app/lib/methods/helpers/info.ts (1)
  • showConfirmationAlert (30-54)
app/lib/services/restApi.ts (1)
  • returnLivechat (433-442)
app/ee/omnichannel/lib/index.ts (2)
app/ee/omnichannel/sagas/inquiry.js (1)
  • serverVersion (17-17)
app/lib/methods/helpers/compareServerVersion.ts (1)
  • compareServerVersion (10-15)
app/views/RoomMembersView/helpers.ts (1)
app/lib/services/restApi.ts (1)
  • toggleMuteUserInRoom (532-559)
app/views/RoomView/index.tsx (2)
app/ee/omnichannel/lib/index.ts (1)
  • takeInquiry (24-30)
app/ee/omnichannel/sagas/inquiry.js (1)
  • serverVersion (17-17)
🔇 Additional comments (7)
app/definitions/rest/v1/omnichannel.ts (1)

22-34: LGTM!

The new endpoint definitions for livechat/config/routing, livechat/inquiries.take, and livechat/inquiries.returnAsInquiry are well-typed and align with the server-version-based routing implementation in restApi.ts.

Also applies to: 138-144

app/views/RoomActionsView/index.tsx (1)

448-463: LGTM!

The handleReturnLivechat method correctly extracts departmentId from the room state and passes it to the updated returnLivechat API, enabling department-aware inquiry return for newer server versions.

app/views/RoomMembersView/helpers.ts (1)

50-59: LGTM!

The handleMute function correctly passes the new userId parameter to toggleMuteUserInRoom, enabling the server-version-based routing to use the new REST endpoints (rooms.muteUser/rooms.unmuteUser) on servers >= 6.8.0.

app/views/RoomView/RightButtons.tsx (1)

234-249: LGTM!

The returnLivechat method correctly extracts departmentId from props and passes it to the service function, consistent with the pattern used in RoomActionsView.

app/lib/services/restApi.ts (3)

433-442: LGTM!

The returnLivechat function correctly implements server-version-based routing, using the new REST endpoint for servers >= 7.12.0 while maintaining backward compatibility with the method call for older servers. The optional departmentId parameter is properly forwarded.


469-488: LGTM!

The getRoutingConfig function is properly converted to async and implements server-version-based routing with appropriate fallback to the method call for older servers.


532-559: LGTM!

The toggleMuteUserInRoom function correctly adds the new userId parameter for the REST endpoints on servers >= 6.8.0 while preserving the username parameter for backward compatibility with older servers using method calls.

Copy link
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: 0

🧹 Nitpick comments (1)
app/lib/services/restApi.ts (1)

471-490: Consider adding a try/catch around the new routing-config REST call.

If sdk.get('livechat/config/routing') rejects (network/404/etc.), getRoutingConfig will currently fail without ever trying the legacy livechat:getRoutingConfig method, even on servers where it still exists. A small try/catch would make this more robust:

 export const getRoutingConfig = async (): Promise<{
@@
 }> => {
 	const serverVersion = reduxStore.getState().server.version;
 	if (compareServerVersion(serverVersion, 'greaterThanOrEqualTo', '7.11.0')) {
-		const result = await sdk.get('livechat/config/routing');
-		if (result.success) {
-			return result.config;
-		}
+		try {
+			const result = await sdk.get('livechat/config/routing');
+			if (result.success) {
+				return result.config;
+			}
+		} catch {
+			// fall through to legacy method
+		}
 	}
 
 	// RC 2.0.0
 	return sdk.methodCallWrapper('livechat:getRoutingConfig');
 };
📜 Review details

Configuration used: CodeRabbit UI

Review profile: CHILL

Plan: Pro

Disabled knowledge base sources:

  • Jira integration is disabled by default for public repositories

You can enable these sources in your CodeRabbit configuration.

📥 Commits

Reviewing files that changed from the base of the PR and between a9c4d37 and 8630d3d.

📒 Files selected for processing (4)
  • app/definitions/rest/v1/rooms.ts (1 hunks)
  • app/ee/omnichannel/lib/index.ts (1 hunks)
  • app/lib/services/restApi.ts (3 hunks)
  • app/views/RoomMembersView/helpers.ts (1 hunks)
🚧 Files skipped from review as they are similar to previous changes (2)
  • app/definitions/rest/v1/rooms.ts
  • app/views/RoomMembersView/helpers.ts
🧰 Additional context used
🧬 Code graph analysis (2)
app/lib/services/restApi.ts (6)
app/ee/omnichannel/sagas/inquiry.js (1)
  • serverVersion (17-17)
app/lib/methods/helpers/compareServerVersion.ts (1)
  • compareServerVersion (10-15)
app/sagas/login.js (3)
  • result (75-75)
  • userId (134-134)
  • userId (341-341)
app/sagas/messages.js (1)
  • result (22-22)
app/sagas/room.js (3)
  • result (96-96)
  • result (122-122)
  • result (146-146)
app/sagas/inviteLinks.js (3)
  • result (20-20)
  • result (29-29)
  • result (51-55)
app/ee/omnichannel/lib/index.ts (2)
app/ee/omnichannel/sagas/inquiry.js (1)
  • serverVersion (17-17)
app/lib/methods/helpers/compareServerVersion.ts (1)
  • compareServerVersion (10-15)
⏰ 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: ESLint and Test / run-eslint-and-test
  • GitHub Check: format
🔇 Additional comments (3)
app/ee/omnichannel/lib/index.ts (1)

23-29: Server-version gating for takeInquiry now aligns with the deprecation path.

Routing >= 7.11.0 to livechat/inquiries.take and older servers to livechat:takeInquiry fixes the earlier inversion and avoids the removed method on 8.0+. Please just confirm 7.11.0 is indeed the minimum version exposing the REST endpoint.

app/lib/services/restApi.ts (2)

433-442: returnLivechat correctly prefers the new REST endpoint for modern servers.

Using livechat/inquiries.returnAsInquiry when serverVersion >= 7.12.0 and falling back to livechat:returnAsInquiry otherwise looks correct and keeps 8.0+ off the removed method. The optional departmentId is passed only where supported. Please double-check that 7.12.0 is the right introduction version for this endpoint.


534-542: toggleMuteUserInRoom version gating and payloads are correctly implemented.

The single call site in app/views/RoomMembersView/helpers.ts (line 52) correctly passes all four arguments including the userId parameter (user?._id). The version gating logic is sound: >= 6.8.0 uses rooms.muteUser/rooms.unmuteUser with { roomId, userId }, and the fallback uses the older muteUserInRoom/unmuteUserInRoom with { rid, username } for older servers.

Copy link
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: 0

🧹 Nitpick comments (1)
app/lib/services/restApi.ts (1)

433-442: Consider using conditional spread for optional departmentId parameter.

The departmentId parameter is always passed to the POST request even when undefined. While this is acceptable (most REST implementations handle undefined fields correctly), it could be more explicit to only include it when defined.

Apply this diff for more explicit optional parameter handling:

 export const returnLivechat = (rid: string, departmentId?: string): Promise<any> => {
 	const serverVersion = reduxStore.getState().server.version;
 
 	if (compareServerVersion(serverVersion, 'greaterThanOrEqualTo', '7.12.0')) {
-		return sdk.post('livechat/inquiries.returnAsInquiry', { roomId: rid, departmentId });
+		return sdk.post('livechat/inquiries.returnAsInquiry', { 
+			roomId: rid, 
+			...(departmentId && { departmentId }) 
+		});
 	}
 
 	// RC 0.72.0
 	return sdk.methodCallWrapper('livechat:returnAsInquiry', rid);
 };
📜 Review details

Configuration used: CodeRabbit UI

Review profile: CHILL

Plan: Pro

Disabled knowledge base sources:

  • Jira integration is disabled by default for public repositories

You can enable these sources in your CodeRabbit configuration.

📥 Commits

Reviewing files that changed from the base of the PR and between 8630d3d and cd739b7.

📒 Files selected for processing (2)
  • app/lib/services/restApi.ts (3 hunks)
  • app/views/RoomMembersView/helpers.ts (1 hunks)
🚧 Files skipped from review as they are similar to previous changes (1)
  • app/views/RoomMembersView/helpers.ts
🧰 Additional context used
🧬 Code graph analysis (1)
app/lib/services/restApi.ts (1)
app/lib/methods/helpers/compareServerVersion.ts (1)
  • compareServerVersion (10-15)
⏰ 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: ESLint and Test / run-eslint-and-test
  • GitHub Check: format
🔇 Additional comments (2)
app/lib/services/restApi.ts (2)

534-541: Call sites correctly updated with userId parameter.

The single call site in app/views/RoomMembersView/helpers.ts:52 has been properly updated to pass all four parameters: toggleMuteUserInRoom(rid, user?.username, user?._id, !user.muted). The migration to userId-based identification improves reliability over username-based lookups.


471-490: The error handling approach here is consistent with similar version-gated functions in the codebase.

The function already includes result.success check to handle endpoint-level failures. Notably, similar version-gated functions like returnLivechat (7.12.0+) and toggleMuteUserInRoom (6.8.0+) return the SDK call directly without any success checking, making them more susceptible to unhandled failures than getRoutingConfig. The codebase architecture intentionally avoids try-catch wrapping for SDK calls, distinguishing between:

  • Endpoint failures: handled via result.success check (as done here)
  • Network/request errors: allowed to propagate (consistent across all version-gated functions)

This pattern is uniform throughout the file and appears intentional.

Likely an incorrect or invalid review comment.

@OtavioStasiak OtavioStasiak merged commit 6250fd7 into develop Dec 16, 2025
5 of 10 checks passed
@OtavioStasiak OtavioStasiak deleted the chore.remove-deprecated-methods-8.0 branch December 16, 2025 23:34
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants