Skip to content

Conversation

@yash-rajpal
Copy link
Member

@yash-rajpal yash-rajpal commented Oct 14, 2025

Proposed changes (including videos or screenshots)

A user can be deactivated for multiple reasons, which was causing some issues with new user approval flow with pending user states. This PR introduces new field on IUser, inactiveReason which specifies the exact reason for a deactivated user.

Issue(s)

Steps to test or reproduce

  • create a new user
  • without logging in with this new user, approve or deactivate user on admin -> users.

Further comments

SUP-835

Summary by CodeRabbit

  • Bug Fixes

    • Users awaiting manual approval no longer show in the Deactivated tab.
  • New Features

    • Admin user lists can be filtered by explicit inactive reasons: pending approval, deactivated, or idle-too-long.
    • New accounts created when manual approval is enabled are marked as pending approval; reactivating an account clears its inactive reason.
  • Tests

    • End-to-end tests updated to cover pending-approval and status-tab flows.

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

@dionisio-bot
Copy link
Contributor

dionisio-bot bot commented Oct 14, 2025

Looks like this PR is not ready to merge, because of the following issues:

  • This PR is targeting the wrong base branch. It should target 7.14.0, but it targets 7.13.0

Please fix the issues and try again

If you have any trouble, please check the PR guidelines

@changeset-bot
Copy link

changeset-bot bot commented Oct 14, 2025

🦋 Changeset detected

Latest commit: 7cf2410

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

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

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 Oct 14, 2025

Walkthrough

Adds an optional user inactiveReason, wires it into user creation and activation/deactivation flows, updates model methods and typings, extends REST params and server-side filtering to accept inactiveReason, adapts admin UI payloads and E2E tests, and removes setAllUsersActive from model API.

Changes

Cohort / File(s) Summary
Changeset
​.changeset/lazy-pianos-care.md
Adds changeset bump entries and notes introducing inactiveReason handling.
Type Definitions
packages/core-typings/src/IUser.ts, packages/rest-typings/src/v1/users/UsersListStatusParamsGET.ts
Add optional `inactiveReason?: ('deactivated'
API Server
apps/meteor/app/api/server/lib/users.ts, apps/meteor/app/api/server/v1/users.ts
Extend findPaginatedUsersByStatus and route to accept inactiveReason; implement query construction to filter by inactiveReason while preserving legacy users lacking the field for compatibility.
Authentication / User Creation
apps/meteor/app/authentication/server/startup/index.js
Default new user active based on manual-approval setting and set inactiveReason: 'pending_approval' when manual approval blocks activation.
Models & Typings
packages/model-typings/src/models/IUsersModel.ts, packages/models/src/models/Users.ts
Remove setAllUsersActive() from interface and implementation; set inactiveReason to 'deactivated' or 'idle_too_long' on deactivation and unset it on reactivation.
Admin UI Hooks
apps/meteor/client/views/admin/users/hooks/useFilteredUsers.ts, apps/meteor/client/views/admin/users/hooks/usePendingUsersCount.ts
Replace hasLoggedIn payloads with inactiveReason arrays for tab-specific API requests (Pending, Active, Deactivated).
E2E Tests
apps/meteor/tests/e2e/admin-users.spec.ts
Toggle Accounts_ManuallyApproveNewUsers in setup/teardown; update test flows and tab assertions to reflect Pending↔Active↔Deactivated transitions.

Sequence Diagram(s)

sequenceDiagram
  actor Admin
  participant UI as Admin UI
  participant API as API Route
  participant UsersSvc as Users Service
  participant DB as Database

  Note over Admin,DB: Create user when manual approval enabled
  Admin->>UI: Submit new user
  UI->>API: POST /users
  API->>UsersSvc: createUser(payload)
  UsersSvc->>DB: insert { active:false, inactiveReason:'pending_approval' }
  DB-->>UsersSvc: created
  UsersSvc-->>API: created
  API-->>UI: success

  rect `#DCEBFF`
  Note over UI,API: List Pending tab uses inactiveReason filter
  UI->>API: GET /users/list-by-status?status=deactivated&inactiveReason=['pending_approval']
  API->>UsersSvc: findPaginatedUsersByStatus(..., inactiveReason)
  UsersSvc->>DB: query inactiveReason IN ['pending_approval'] OR legacy (no field)
  DB-->>UsersSvc: results
  UsersSvc-->>API: users
  API-->>UI: render Pending tab
  end

  rect `#E6FFE6`
  Note over UI,API: Approve user (activate)
  Admin->>UI: Activate user
  UI->>API: PATCH /users/:id active=true
  API->>UsersSvc: setUserActive(id, true)
  UsersSvc->>DB: update { active:true, $unset:{ inactiveReason:1 } }
  DB-->>UsersSvc: updated
  UsersSvc-->>API: updated
  API-->>UI: refresh lists
  end
Loading

Estimated code review effort

🎯 3 (Moderate) | ⏱️ ~25 minutes

  • Review backward-compatibility logic in apps/meteor/app/api/server/lib/users.ts (handling users without inactiveReason).
  • Verify all activation/deactivation paths in packages/models/src/models/Users.ts consistently set/unset inactiveReason.
  • Ensure setAllUsersActive() removal leaves no callers and packages/model-typings updated.
  • Confirm REST schema and client payload shapes match and tests reflect behavior.

Possibly related PRs

Suggested reviewers

  • tassoevan
  • gabriellsh
  • ggazzo

Poem

🐰 I hopped through branches, quick and merry,

Tagged sleepers tiny, soft, and wary.
Pending, idle, gone to rest —
Now each buddy sits in the right nest. 🥕

Pre-merge checks and finishing touches

✅ 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 'feat: User inactiveReason' clearly summarizes the main change: introducing a new inactiveReason field to distinguish user deactivation reasons.
Linked Issues check ✅ Passed The PR fully addresses the linked issue SUP-835 by implementing the inactiveReason field to correctly distinguish between pending and deactivated users.
Out of Scope Changes check ✅ Passed All changes are directly scoped to implementing the inactiveReason feature; no unrelated modifications detected.
Docstring Coverage ✅ Passed No functions found in the changed files to evaluate docstring coverage. Skipping docstring coverage check.
✨ Finishing touches
🧪 Generate unit tests (beta)
  • Create PR with unit tests
  • Post copyable unit tests in a comment
  • Commit unit tests in branch feat/user-state

📜 Recent 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 91ec45d and 6ca14b4.

📒 Files selected for processing (1)
  • .changeset/lazy-pianos-care.md (1 hunks)
✅ Files skipped from review due to trivial changes (1)
  • .changeset/lazy-pianos-care.md
⏰ 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

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

codecov bot commented Oct 14, 2025

Codecov Report

✅ All modified and coverable lines are covered by tests.
✅ Project coverage is 68.88%. Comparing base (42bb8a3) to head (7cf2410).
⚠️ Report is 1 commits behind head on develop.

Additional details and impacted files

Impacted file tree graph

@@             Coverage Diff             @@
##           develop   #37224      +/-   ##
===========================================
+ Coverage    68.82%   68.88%   +0.05%     
===========================================
  Files         3361     3361              
  Lines       114265   114329      +64     
  Branches     20619    20643      +24     
===========================================
+ Hits         78646    78753     +107     
+ Misses       33530    33492      -38     
+ Partials      2089     2084       -5     
Flag Coverage Δ
e2e 57.37% <ø> (+0.08%) ⬆️
e2e-api 43.31% <ø> (+0.09%) ⬆️

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.

@yash-rajpal yash-rajpal changed the base branch from develop to release-8.0.0 October 29, 2025 12:09
@ggazzo ggazzo force-pushed the release-8.0.0 branch 5 times, most recently from 329ef07 to 8fa1cac Compare October 31, 2025 19:22
@yash-rajpal yash-rajpal changed the base branch from release-8.0.0 to develop November 4, 2025 18:31
@github-actions
Copy link
Contributor

github-actions bot commented Nov 19, 2025

📦 Docker Image Size Report

📈 Changes

Service Current Baseline Change Percent
sum of all images 1.2GiB 1.2GiB +12MiB
rocketchat 359MiB 347MiB +12MiB
omnichannel-transcript-service 132MiB 132MiB +1.1KiB
queue-worker-service 132MiB 132MiB +796B
ddp-streamer-service 127MiB 127MiB +389B
account-service 114MiB 114MiB +2.3KiB
stream-hub-service 111MiB 111MiB +878B
authorization-service 111MiB 111MiB +869B
presence-service 111MiB 111MiB +1.7KiB

📊 Historical Trend

---
config:
  theme: "dark"
  xyChart:
    width: 900
    height: 400
---
xychart
  title "Image Size Evolution by Service (Last 30 Days + This PR)"
  x-axis ["11/15 22:28", "11/16 01:28", "11/17 23:50", "11/18 22:53", "11/19 23:02", "11/21 16:49", "11/24 17:34", "11/27 22:32", "11/28 19:05", "12/01 13:34", "12/01 15:07 (PR)"]
  y-axis "Size (GB)" 0 --> 0.5
  line "account-service" [0.11, 0.11, 0.11, 0.11, 0.11, 0.11, 0.11, 0.11, 0.11, 0.11, 0.11]
  line "authorization-service" [0.11, 0.11, 0.11, 0.11, 0.11, 0.11, 0.11, 0.11, 0.11, 0.11, 0.11]
  line "ddp-streamer-service" [0.12, 0.12, 0.12, 0.12, 0.12, 0.12, 0.12, 0.12, 0.12, 0.12, 0.12]
  line "omnichannel-transcript-service" [0.14, 0.14, 0.14, 0.14, 0.14, 0.13, 0.13, 0.13, 0.13, 0.13, 0.13]
  line "presence-service" [0.11, 0.11, 0.11, 0.11, 0.11, 0.11, 0.11, 0.11, 0.11, 0.11, 0.11]
  line "queue-worker-service" [0.14, 0.14, 0.14, 0.14, 0.14, 0.13, 0.13, 0.13, 0.13, 0.13, 0.13]
  line "rocketchat" [0.36, 0.36, 0.35, 0.35, 0.35, 0.34, 0.34, 0.34, 0.34, 0.34, 0.35]
  line "stream-hub-service" [0.11, 0.11, 0.11, 0.11, 0.11, 0.11, 0.11, 0.11, 0.11, 0.11, 0.11]
Loading

Statistics (last 10 days):

  • 📊 Average: 1.5GiB
  • ⬇️ Minimum: 1.2GiB
  • ⬆️ Maximum: 1.6GiB
  • 🎯 Current PR: 1.2GiB
ℹ️ About this report

This report compares Docker image sizes from this build against the develop baseline.

  • Tag: pr-37224
  • Baseline: develop
  • Timestamp: 2025-12-01 15:07:54 UTC
  • Historical data points: 10

Updated: Mon, 01 Dec 2025 15:07:54 GMT

@yash-rajpal yash-rajpal added this to the 7.13.0 milestone Nov 19, 2025
@yash-rajpal yash-rajpal added the stat: QA assured Means it has been tested and approved by a company insider label Nov 19, 2025
@dionisio-bot dionisio-bot bot added the stat: ready to merge PR tested and approved waiting for merge label Nov 19, 2025
@scuciatto scuciatto modified the milestones: 7.13.0, 7.14.0 Nov 20, 2025
KevLehman
KevLehman previously approved these changes Nov 20, 2025
Copy link
Member

@KevLehman KevLehman left a comment

Choose a reason for hiding this comment

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

I'm still not happy with the changeset 🙈

We also agreed with Yash to try some improvements on the queries for that page in a future task.

@scuciatto scuciatto modified the milestones: 7.14.0, 7.13.0 Nov 20, 2025
Copy link
Contributor

@tassoevan tassoevan left a comment

Choose a reason for hiding this comment

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

The disagreement over the changeset is rooted under the nature of this modification: it started as a simple bug report/support request but evolved into introducing a new concept (reason for a user's inactive state). @KevLehman and @gabriellsh made valid points suggesting this is a fix, but IMHO it's a feature and the changeset description must be rephrased as such. I stand over previously "What's New" entries to affirm it.

KevLehman
KevLehman previously approved these changes Nov 27, 2025
@kodiakhq kodiakhq bot merged commit ddc9357 into develop Dec 1, 2025
48 checks passed
@kodiakhq kodiakhq bot deleted the feat/user-state branch December 1, 2025 15:33
@dougfabris dougfabris modified the milestones: 7.14.0, 8.0.0 Jan 19, 2026
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.

7 participants