chore: remove deprecated methods for livechat in 8.0 #7058
chore: remove deprecated methods for livechat in 8.0 #7058
Conversation
|
No actionable comments were generated in the recent review. 🎉 ℹ️ Recent review info⚙️ Run configurationConfiguration used: Organization UI Review profile: CHILL Plan: Pro Run ID: 📒 Files selected for processing (1)
🚧 Files skipped from review as they are similar to previous changes (1)
📜 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). (2)
WalkthroughUpdates REST endpoint definitions (omnichannel + users) and changes client-side services to prefer new REST calls for server versions >= 8.0.0 while preserving legacy method-wrapper fallbacks for older servers. Changes
Sequence Diagram(s)sequenceDiagram
participant UI as Client UI
participant Service as restApi Service
participant Store as Redux Store
participant SDK as SDK (methodCallWrapper / REST)
participant Server as Server API
UI->>Service: invoke action (e.g., change status / resume / close / forward / send confirmation / get tags)
Service->>Store: read server.version
alt server.version >= "8.0.0"
Service->>SDK: POST new REST endpoint (e.g., livechat/agent.status, livechat/room.resumeOnHold, users.sendConfirmationEmail, livechat/room.closeByUser, livechat/room.forward, livechat/tags)
SDK->>Server: HTTP POST/GET to REST API
Server-->>SDK: REST response ({ success: boolean, ... })
SDK-->>Service: return response
else older server
Service->>SDK: call legacy method wrapper (e.g., livechat:changeLivechatStatus, livechat:resumeOnHold, sendConfirmationEmail, livechat:closeRoom, livechat:transfer, livechat:getTagsList)
SDK->>Server: DDP method call
Server-->>SDK: method response
SDK-->>Service: return response
end
Service-->>UI: resolve promise / return result
Estimated code review effort🎯 4 (Complex) | ⏱️ ~45 minutes Suggested labels
🚥 Pre-merge checks | ✅ 5✅ Passed checks (5 passed)
✏️ Tip: You can configure your own custom pre-merge checks in the settings. 📝 Coding Plan
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 |
There was a problem hiding this comment.
Actionable comments posted: 1
🧹 Nitpick comments (1)
app/lib/services/restApi.ts (1)
456-463: Consider adding type definition fortransferData.The
transferDataparameter is typed asany, which loses type safety. The type definition forlivechat/room.forwardinomnichannel.tsspecifies{ roomId: string; userId?: string; departmentId?: string }.♻️ Proposed type improvement
-export const forwardLivechat = (transferData: any) => { +export const forwardLivechat = (transferData: { roomId: string; userId?: string; departmentId?: string }) => { const serverVersion = reduxStore.getState().server.version; if (compareServerVersion(serverVersion, 'greaterThanOrEqualTo', '8.0.0')) { return sdk.post('livechat/room.forward', transferData); } // RC 0.36.0 return sdk.methodCallWrapper('livechat:transfer', transferData); };🤖 Prompt for AI Agents
Verify each finding against the current code and only fix it if needed. In `@app/lib/services/restApi.ts` around lines 456 - 463, forwardLivechat currently types transferData as any, losing type safety; replace any with the proper typed shape used for the RPC "livechat/room.forward" (e.g. the interface/type from omnichannel.ts: { roomId: string; userId?: string; departmentId?: string }) so that forwardLivechat(transferData: ...) uses that specific type; update the function signature in forwardLivechat and any callers if needed to import and use the shared type (referencing forwardLivechat and the type declared in omnichannel.ts) to ensure consistent typing across SDK.post('livechat/room.forward') and sdk.methodCallWrapper('livechat:transfer').
🤖 Prompt for all review comments with AI agents
Verify each finding against the current code and only fix it if needed.
Inline comments:
In `@app/ee/omnichannel/lib/index.ts`:
- Around line 10-17: The function changeLivechatStatus has an unused parameter
`status`; remove it from the signature and stop passing it into the legacy call.
Update export const changeLivechatStatus = () => { ... } and change the fallback
call from sdk.methodCallWrapper('livechat:changeLivechatStatus', status) to
sdk.methodCallWrapper('livechat:changeLivechatStatus') (and adjust any
TypeScript signatures/types accordingly). Keep the compareServerVersion check
and the sdk.post('livechat/agent.status') call unchanged.
---
Nitpick comments:
In `@app/lib/services/restApi.ts`:
- Around line 456-463: forwardLivechat currently types transferData as any,
losing type safety; replace any with the proper typed shape used for the RPC
"livechat/room.forward" (e.g. the interface/type from omnichannel.ts: { roomId:
string; userId?: string; departmentId?: string }) so that
forwardLivechat(transferData: ...) uses that specific type; update the function
signature in forwardLivechat and any callers if needed to import and use the
shared type (referencing forwardLivechat and the type declared in
omnichannel.ts) to ensure consistent typing across
SDK.post('livechat/room.forward') and
sdk.methodCallWrapper('livechat:transfer').
🪄 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: 266a2572-ccd5-4b8e-8523-edde49b68e7a
📒 Files selected for processing (4)
app/definitions/rest/v1/omnichannel.tsapp/definitions/rest/v1/users.tsapp/ee/omnichannel/lib/index.tsapp/lib/services/restApi.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). (1)
- GitHub Check: format
🔇 Additional comments (7)
app/definitions/rest/v1/omnichannel.ts (2)
139-148: LGTM!The updated type definitions for
livechat/inquiries.take(adding optionaluserIdparam and returning{ success: boolean }) andlivechat/inquiries.returnAsInquiry(returning{ result: boolean; success: boolean }) align with the migration to REST endpoints.
259-292: LGTM!The endpoint type definitions for livechat operations are well-structured and correctly implemented. All five endpoints (
livechat/agent.status,livechat/room.closeByUser,livechat/room.forward,livechat/tags, andlivechat/room.resumeOnHold) properly type both request parameters and response shapes, and their usage throughout the codebase confirms the type signatures are accurate.app/definitions/rest/v1/users.ts (1)
72-74: LGTM!The new
users.sendConfirmationEmailendpoint type definition is correctly structured and follows the established pattern for POST endpoints in this file.app/ee/omnichannel/lib/index.ts (1)
40-47: LGTM!The
takeResumefunction correctly implements version branching and properly passes theroomIdparameter to the newlivechat/room.resumeOnHoldendpoint.app/lib/services/restApi.ts (3)
109-116: LGTM!The
sendConfirmationEmailfunction correctly implements version branching with consistent return typePromise<{ success: boolean }>for both the new REST endpoint and the legacy method wrapper.
419-431: LGTM!The
closeLivechatfunction correctly implements version branching. The newlivechat/room.closeByUserendpoint receives the required parameters (rid,comment, and optionaltags), while the legacy fallback maintains backward compatibility.
507-518: LGTM!The
getTagsListfunction correctly implements version branching with proper defensive coding. The success check and fallback to an empty array ensures graceful handling of API failures.
Proposed changes
Remove deprecated methods based on https://docs.rocket.chat/docs/deprecated-and-phasing-out-features.
New endpoints
livechat/agent.statuslivechat/room.resumeOnHoldusers.sendConfirmationEmaillivechat/room.closeByUserlivechat/room.forwardlivechat/tagsDeprecated methods
livechat:changeLivechatStatuslivechat:resumeOnHoldsendConfirmationEmaillivechat:closeRoomlivechat:transferlivechat:getTagsListIssue(s)
https://rocketchat.atlassian.net/browse/SUP-1008
How to test or reproduce
Screenshots
Types of changes
Checklist
Further comments
Summary by CodeRabbit
New Features
Changes