Skip to content

Conversation

@lucas-a-pelegrino
Copy link
Contributor

@lucas-a-pelegrino lucas-a-pelegrino commented Sep 11, 2025

Proposed changes (including videos or screenshots)

This PR adds a deprecation warning log on livechat:removeAllClosedRooms, as well as it adds a new endpoint (livechat/rooms.removeAllClosedRooms) that replaces it using the same logic and business rules.

Issue(s)

CTZ-58

Steps to test or reproduce

Further comments

Tests will be implemented on this task

Summary by CodeRabbit

  • New Features
    • Added REST API POST /v1/livechat/rooms.removeAllClosedRooms to remove closed Livechat rooms (optional department filter, returns removed count).
  • Deprecation
    • Deprecated the livechat:removeAllClosedRooms RPC method with deprecation logging; use the new REST endpoint.
  • Refactor
    • Livechat UI switched from RPC to the new REST endpoint; confirmations, reloads, and success toasts preserved.
  • Chores
    • Bumped patch versions and added request/response validators and REST typings for the new endpoint.

@dionisio-bot
Copy link
Contributor

dionisio-bot bot commented Sep 11, 2025

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

@changeset-bot
Copy link

changeset-bot bot commented Sep 11, 2025

🦋 Changeset detected

Latest commit: 22c5685

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

This PR includes changesets to release 39 packages
Name Type
@rocket.chat/meteor Patch
@rocket.chat/rest-typings Patch
@rocket.chat/api-client Patch
@rocket.chat/core-services Patch
@rocket.chat/ddp-client Patch
@rocket.chat/http-router Patch
@rocket.chat/models Patch
@rocket.chat/ui-contexts Patch
@rocket.chat/web-ui-registration Patch
@rocket.chat/account-service Patch
@rocket.chat/authorization-service Patch
@rocket.chat/ddp-streamer Patch
@rocket.chat/stream-hub-service Patch
@rocket.chat/omnichannel-services Patch
@rocket.chat/presence Patch
rocketchat-services Patch
@rocket.chat/omnichannel-transcript Patch
@rocket.chat/presence-service Patch
@rocket.chat/queue-worker Patch
@rocket.chat/network-broker Patch
@rocket.chat/omni-core-ee Patch
@rocket.chat/livechat Patch
@rocket.chat/mock-providers Patch
@rocket.chat/cron Patch
@rocket.chat/instance-status Patch
@rocket.chat/omni-core Patch
@rocket.chat/uikit-playground Patch
@rocket.chat/fuselage-ui-kit Patch
@rocket.chat/gazzodown Patch
@rocket.chat/ui-avatar Patch
@rocket.chat/ui-client Patch
@rocket.chat/ui-video-conf Patch
@rocket.chat/ui-voip Patch
@rocket.chat/core-typings Patch
@rocket.chat/apps Patch
@rocket.chat/freeswitch Patch
@rocket.chat/model-typings 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
Contributor

coderabbitai bot commented Sep 11, 2025

Walkthrough

Adds a new REST endpoint POST /v1/livechat/rooms.removeAllClosedRooms to remove closed livechat rooms (optionally by department), logs deprecation for the Meteor method livechat:removeAllClosedRooms, migrates clients to the REST endpoint, extends REST typings with request/response validators, and adds a changeset.

Changes

Cohort / File(s) Summary
REST endpoint & server logic
apps/meteor/app/livechat/server/api/v1/room.ts
Adds POST livechat/rooms.removeAllClosedRooms with auth/permission checks, request/response validation, applies room restrictions, iterates closed rooms via LivechatRooms.findClosedRooms, calls removeOmnichannelRoom for each, logs actions, returns { removedRooms }, imports IOmnichannelRoom, ExtractRoutesFromAPI, and augments @rocket.chat/rest-typings.
Deprecated Meteor method
apps/meteor/app/livechat/server/methods/removeAllClosedRooms.ts
Adds deprecation instrumentation: methodDeprecationLogger.method('livechat:removeAllClosedRooms', '8.0.0', '/v1/livechat/rooms.removeAllClosedRooms') at method start; existing logic and ServerMethods signature remain.
Client UI updates
apps/meteor/client/views/omnichannel/currentChats/FilterByText.tsx, apps/meteor/client/views/omnichannel/directory/chats/ChatsTable/ChatsTableFilter.tsx
Replace useMethod('livechat:removeAllClosedRooms') with useEndpoint('POST', '/v1/livechat/rooms.removeAllClosedRooms'); invoke endpoint (no payload) and preserve modal/toast/cache behavior.
REST typings & validators
packages/rest-typings/src/v1/omnichannel.ts
Adds POSTLivechatRoomsCloseAll schema and exported validator isPOSTLivechatRoomsCloseAll, plus POSTLivechatRoomsCloseAllSuccessResponseSchema and exported isPOSTLivechatRoomsCloseAllSuccessResponse (response typed { removedRooms: number }).
Release metadata
.changeset/ninety-rocks-hope.md
Adds changeset bumping patch versions for @rocket.chat/meteor and @rocket.chat/rest-typings; documents deprecation and replacement endpoint.

Sequence Diagram(s)

sequenceDiagram
  autonumber
  actor Client as UI
  participant REST as POST /v1/livechat/rooms.removeAllClosedRooms
  participant Auth as Auth & Permissions
  participant Validator as Request/Response Validator
  participant Rooms as LivechatRooms
  participant Logic as removeOmnichannelRoom

  Client->>REST: POST { departmentIds? }
  REST->>Auth: verify user & permission
  Auth-->>REST: authorized
  REST->>Validator: validate request
  Validator-->>REST: valid
  REST->>Rooms: findClosedRooms(departmentIds, restrictions)
  Rooms-->>REST: [rooms]
  loop per room
    REST->>Logic: removeOmnichannelRoom(room._id)
    Logic-->>REST: removed
  end
  REST->>Validator: validate response
  REST-->>Client: 200 { removedRooms, success: true }
Loading
sequenceDiagram
  autonumber
  actor Client
  participant Method as Meteor method livechat:removeAllClosedRooms
  note over Method: Deprecated — logs replacement endpoint
  Client->>Method: invoke()
  Method-->>Client: removedRooms count (legacy)
Loading

Estimated code review effort

🎯 3 (Moderate) | ⏱️ ~25 minutes

Suggested labels

stat: ready to merge

Suggested reviewers

  • aleksandernsilva
  • sampaiodiego
  • ggazzo

Poem

A rabbit hops to tidy the den,
Closed rooms counted, swept again.
Old method whispers "soon replaced,"
New REST path guides the swift erase.
Logs and validators hum—clean code, bright pen. 🥕

Pre-merge checks and finishing touches

✅ Passed checks (3 passed)
Check name Status Explanation
Description Check ✅ Passed Check skipped - CodeRabbit’s high-level summary is enabled.
Title Check ✅ Passed The title accurately and concisely describes the primary change: adding a deprecation warning for the Meteor method livechat:removeAllClosedRooms and introducing a replacement REST endpoint. It matches the PR objectives and the file-level changes (deprecation logging, new POST /v1/livechat/rooms.removeAllClosedRooms, and client updates). The phrasing is specific and clear enough for a teammate scanning history.
Docstring Coverage ✅ Passed No functions found in the changes. Docstring coverage check skipped.
✨ Finishing touches
  • 📝 Generate Docstrings
🧪 Generate unit tests
  • Create PR with unit tests
  • Post copyable unit tests in a comment
  • Commit unit tests in branch chore/v7/CTZ-58

📜 Recent review details

Configuration used: CodeRabbit UI

Review profile: CHILL

Plan: Pro

📥 Commits

Reviewing files that changed from the base of the PR and between 06273b1 and da72904.

📒 Files selected for processing (1)
  • packages/rest-typings/src/v1/omnichannel.ts (1 hunks)
🚧 Files skipped from review as they are similar to previous changes (1)
  • packages/rest-typings/src/v1/omnichannel.ts
⏰ 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

Tip

👮 Agentic pre-merge checks are now available in preview!

Pro plan users can now enable pre-merge checks in their settings to enforce checklists before merging PRs.

  • Built-in checks – Quickly apply ready-made checks to enforce title conventions, require pull request descriptions that follow templates, validate linked issues for compliance, and more.
  • Custom agentic checks – Define your own rules using CodeRabbit’s advanced agentic capabilities to enforce organization-specific policies and workflows. For example, you can instruct CodeRabbit’s agent to verify that API documentation is updated whenever API schema files are modified in a PR. Note: Upto 5 custom checks are currently allowed during the preview period. Pricing for this feature will be announced in a few weeks.

Please see the documentation for more information.

Example:

reviews:
  pre_merge_checks:
    custom_checks:
      - name: "Undocumented Breaking Changes"
        mode: "warning"
        instructions: |
          Pass/fail criteria: All breaking changes to public APIs, CLI flags, environment variables, configuration keys, database schemas, or HTTP/GraphQL endpoints must be documented in the "Breaking Change" section of the PR description and in CHANGELOG.md. Exclude purely internal or private changes (e.g., code not exported from package entry points or explicitly marked as internal).

Please share your feedback with us on this Discord post.


Comment @coderabbitai help to get the list of available commands and usage tips.

@codecov
Copy link

codecov bot commented Sep 11, 2025

Codecov Report

❌ Patch coverage is 50.00000% with 2 lines in your changes missing coverage. Please review.
✅ Project coverage is 66.56%. Comparing base (ab7d810) to head (22c5685).
⚠️ Report is 1 commits behind head on develop.

Additional details and impacted files

Impacted file tree graph

@@             Coverage Diff             @@
##           develop   #36921      +/-   ##
===========================================
- Coverage    66.58%   66.56%   -0.03%     
===========================================
  Files         3346     3346              
  Lines       114666   114666              
  Branches     21097    21118      +21     
===========================================
- Hits         76350    76326      -24     
- Misses       35617    35650      +33     
+ Partials      2699     2690       -9     
Flag Coverage Δ
e2e 57.78% <50.00%> (-0.03%) ⬇️
unit 71.22% <ø> (+<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.

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 (6)
apps/meteor/app/livechat/server/methods/removeAllClosedRooms.ts (1)

26-28: Fix typo in error payload method name.

The method field says livechat:removeAllClosedRoom (missing “s”). Align it with the actual method key.

-        method: 'livechat:removeAllClosedRoom',
+        method: 'livechat:removeAllClosedRooms',
packages/rest-typings/src/v1/omnichannel.ts (2)

3845-3861: Avoid ambiguous empty-array semantics in request schema.

If clients send departmentIds: [], it’s unclear whether that means “no filter” or “match none.” Enforce at least one item so callers either omit the field or pass a non-empty list. Coordinate with server and clients.

 		departmentIds: {
 			type: 'array',
 			items: {
 				type: 'string',
 			},
-			nullable: true,
+			minItems: 1,
+			nullable: true,
 		},

3865-3882: Type the success flag in the validator’s generic for stronger DX (optional).

Runtime allows success: true, but TypeScript consumers won’t see it. Consider including it in the generic for the compiled validator.

-export const isPOSTLivechatRoomsCloseAllSuccessResponse = ajv.compile<{ removedRooms: number }>(
+export const isPOSTLivechatRoomsCloseAllSuccessResponse = ajv.compile<{ removedRooms: number; success: true }>(
 	POSTLivechatRoomsCloseAllSuccessResponseSchema,
 );
.changeset/ninety-rocks-hope.md (1)

6-6: Clarify the replacement endpoint format in the changeset.

Spell out the HTTP method and full path for clarity: “POST /v1/livechat/rooms.removeAllClosedRooms”.

-Adds deprecation warning on livechat:removeAllClosedRooms with new endpoint replacing it; `livechat/rooms.removeAllClosedRooms`
+Adds deprecation warning on livechat:removeAllClosedRooms with new endpoint replacing it; `POST /v1/livechat/rooms.removeAllClosedRooms`
apps/meteor/app/livechat/server/api/v1/room.ts (2)

441-449: Consider a basic rate limit for this destructive endpoint.

A small limiter (e.g., 1–2 requests/min per user) reduces accidental repeated bulk deletions.


457-463: Optional: add bounded concurrency instead of fully sequential or unbounded parallelism.

If you want faster execution without spikes, wrap deletions with a small concurrency limiter (e.g., p-limit 5–10). Keep per-request memory bounded.

📜 Review details

Configuration used: CodeRabbit UI

Review profile: CHILL

Plan: Pro

📥 Commits

Reviewing files that changed from the base of the PR and between a89f0e5 and d7f1e10.

📒 Files selected for processing (6)
  • .changeset/ninety-rocks-hope.md (1 hunks)
  • apps/meteor/app/livechat/server/api/v1/room.ts (4 hunks)
  • apps/meteor/app/livechat/server/methods/removeAllClosedRooms.ts (2 hunks)
  • apps/meteor/client/views/omnichannel/currentChats/FilterByText.tsx (2 hunks)
  • apps/meteor/client/views/omnichannel/directory/chats/ChatsTable/ChatsTableFilter.tsx (2 hunks)
  • packages/rest-typings/src/v1/omnichannel.ts (1 hunks)
🧰 Additional context used
🧬 Code graph analysis (3)
apps/meteor/client/views/omnichannel/directory/chats/ChatsTable/ChatsTableFilter.tsx (2)
packages/ui-contexts/src/index.ts (1)
  • useEndpoint (32-32)
apps/meteor/client/views/omnichannel/directory/contexts/ChatsContext.ts (1)
  • useChatsContext (64-71)
apps/meteor/client/views/omnichannel/currentChats/FilterByText.tsx (1)
packages/ui-contexts/src/index.ts (1)
  • useEndpoint (32-32)
apps/meteor/app/livechat/server/api/v1/room.ts (6)
apps/meteor/app/api/server/api.ts (1)
  • API (42-77)
packages/rest-typings/src/v1/omnichannel.ts (2)
  • isPOSTLivechatRoomsCloseAllSuccessResponse (3880-3882)
  • isPOSTLivechatRoomsCloseAll (3863-3863)
apps/meteor/app/livechat/server/lib/logger.ts (1)
  • livechatLogger (5-5)
apps/meteor/app/livechat/server/methods/removeAllClosedRooms.ts (1)
  • departmentIds (20-43)
apps/meteor/app/livechat/server/lib/rooms.ts (1)
  • removeOmnichannelRoom (257-292)
apps/meteor/app/api/server/ApiClass.ts (1)
  • ExtractRoutesFromAPI (71-75)
⏰ 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 comments (2)
apps/meteor/app/livechat/server/methods/removeAllClosedRooms.ts (1)

21-21: Deprecation instrumentation LGTM.

The deprecation notice clearly points callers to the replacement endpoint and is versioned for 8.0.0.

apps/meteor/client/views/omnichannel/directory/chats/ChatsTable/ChatsTableFilter.tsx (1)

17-25: Don't send departmentIds: [] — omit the field or pass selected department IDs

Empty arrays are often treated as "match none". Omit departmentIds to act on all permitted departments or pass the selected department IDs instead.

Locations:

  • Client: apps/meteor/client/views/omnichannel/directory/chats/ChatsTable/ChatsTableFilter.tsx (lines 17-25)
  • Server: apps/meteor/app/livechat/server/methods/removeAllClosedRooms.ts (calls LivechatRooms.findClosedRooms), apps/meteor/app/livechat/server/api/v1/room.ts (calls LivechatRooms.findClosedRooms)
-  const removeClosedRooms = useEndpoint('POST', '/v1/livechat/rooms.removeAllClosedRooms');
+  const removeClosedRooms = useEndpoint('POST', '/v1/livechat/rooms.removeAllClosedRooms');
@@
-        await removeClosedRooms({ departmentIds: [] });
+        // No department filter here — request server default (all permitted)
+        const { removedRooms } = await removeClosedRooms({});
+        // Optional: surface count to the user (keep existing i18n if preferred)
+        // dispatchToastMessage({ type: 'success', message: t('Chats_removed_count', { count: removedRooms }) });

@lucas-a-pelegrino lucas-a-pelegrino marked this pull request as ready for review September 12, 2025 19:49
@lucas-a-pelegrino lucas-a-pelegrino requested review from a team as code owners September 12, 2025 19:49
Copy link
Contributor

@aleksandernsilva aleksandernsilva left a comment

Choose a reason for hiding this comment

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

Suggestion: Upgrading the logic to useMutation or useEndpointMutation would be a good addition to ensure these components are following best practices. Could be done here or in a separate PR since the change is minimal.

@lucas-a-pelegrino lucas-a-pelegrino added the stat: QA assured Means it has been tested and approved by a company insider label Sep 16, 2025
@lucas-a-pelegrino lucas-a-pelegrino added the stat: ready to merge PR tested and approved waiting for merge label Sep 16, 2025
@lucas-a-pelegrino lucas-a-pelegrino added this to the 7.11.0 milestone Sep 16, 2025
@kodiakhq kodiakhq bot merged commit 276c270 into develop Sep 16, 2025
49 checks passed
@kodiakhq kodiakhq bot deleted the chore/v7/CTZ-58 branch September 16, 2025 20:39
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

Projects

None yet

Development

Successfully merging this pull request may close these issues.

4 participants