feat: Add phone support to user#40697
Conversation
|
Looks like this PR is not ready to merge, because of the following issues:
Please fix the issues and try again If you have any trouble, please check the PR guidelines |
|
|
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 ignored due to path filters (2)
📒 Files selected for processing (14)
✅ Files skipped from review due to trivial changes (1)
🚧 Files skipped from review as they are similar to previous changes (6)
📜 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)
🧰 Additional context used📓 Path-based instructions (3)**/*.{ts,tsx,js}📄 CodeRabbit inference engine (.cursor/rules/playwright.mdc)
Files:
apps/meteor/tests/e2e/page-objects/**/*.ts📄 CodeRabbit inference engine (.cursor/rules/playwright.mdc)
Files:
apps/meteor/tests/e2e/**/*.{ts,spec.ts}📄 CodeRabbit inference engine (.cursor/rules/playwright.mdc)
Files:
🪛 ast-grep (0.43.0)apps/meteor/tests/e2e/page-objects/fragments/phone-number-field-list.ts[warning] 14-14: Regular expression constructed from variable input detected. This can lead to Regular Expression Denial of Service (ReDoS) attacks if the variable contains malicious patterns. Use libraries like 'recheck' to validate regex safety or use static patterns. (regexp-from-variable) 🔇 Additional comments (7)
WalkthroughThis PR implements multi-phone number support across Rocket.Chat. Users can now have multiple phone numbers with optional labels and metadata (primary, verified flags). The legacy single ChangesMulti-phone Support Feature
Estimated code review effort🎯 3 (Moderate) | ⏱️ ~25 minutes Suggested labels
Suggested reviewers
🚥 Pre-merge checks | ✅ 4 | ❌ 1❌ Failed checks (1 warning)
✅ Passed checks (4 passed)
✏️ 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. Comment |
Codecov Report❌ Patch coverage is Additional details and impacted files@@ Coverage Diff @@
## develop #40697 +/- ##
===========================================
+ Coverage 69.71% 69.80% +0.09%
===========================================
Files 3339 3329 -10
Lines 123269 123283 +14
Branches 21971 22029 +58
===========================================
+ Hits 85931 86061 +130
+ Misses 33990 33859 -131
- Partials 3348 3363 +15
Flags with carried forward coverage won't be shown. Click here to find out more. 🚀 New features to boost your workflow:
|
|
@coderabbitai review |
✅ Actions performedReview triggered.
|
There was a problem hiding this comment.
Actionable comments posted: 7
🤖 Prompt for all review comments with AI agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.
Inline comments:
In `@apps/meteor/client/components/PhoneNumberFieldList/PhoneNumberFieldList.tsx`:
- Around line 45-51: The required validator in PhoneNumberFieldList's rules
currently calls value.trim() which throws if value is undefined; update the
required validator (inside rules.validate) to guard against undefined (e.g., use
optional chaining or a null check such as value?.trim() or typeof value ===
'string' before trimming) so validation returns the localized "Required_field"
message when value is missing instead of throwing a TypeError.
In `@apps/meteor/client/components/UserInfo/UserInfo.tsx`:
- Around line 174-185: The list uses phones.map in the UserInfo component with
key={p.number}, which can collide for entries sharing the same number; update
the map call to include the index (or another unique field) in the key to make
it collision-resistant—e.g., change the map callback signature to (p, i) and set
the key to a combined value such as `${p.number}-${i}` (or use p.id if
available) on the Box element that currently uses key={p.number}; this ensures
stable, unique keys for reconciliation while keeping formatPhoneNumber and the
existing JSX intact.
In `@apps/meteor/tests/e2e/account-profile.spec.ts`:
- Around line 97-99: The test clicks poAccountProfile.btnSaveChanges and
immediately calls page.reload(), causing a race; instead wait for a web-first
completion signal (e.g. the success toast used elsewhere) before reloading.
Update both occurrences (around the click at the first block and the one at
lines 122-124) to wait for the success toast or equivalent completion element
from poAccountProfile (e.g. poAccountProfile.toastSuccess or its selector) to be
visible/attached (or wait for the save button to become enabled/hidden) and only
then call page.reload() so the profile update has completed before assertions.
In `@apps/meteor/tests/e2e/page-objects/fragments/phone-number-field-list.ts`:
- Around line 14-15: The locator in getPhoneLabelInput uses a loose regex that
can match "10" when index is 0; update the regex passed to this.root.getByRole
(used in getPhoneLabelInput) to match the exact indexed label (e.g., anchor the
pattern with an end anchor or word boundary so it only matches the specific
`${index + 1}`) so the locator targets the correct textbox even when there are
10+ phone rows.
In `@packages/i18n/src/locales/pt-BR.i18n.json`:
- Around line 4142-4143: Replace the current placeholder values for the locale
keys Phone_number_placeholder and Phone_label_placeholder to use pt-BR
abbreviation style "Ex.:" instead of "ex.,": update the string for
"Phone_number_placeholder" from "ex., +55 11 91234 5678" to "Ex.: +55 11 91234
5678" and update "Phone_label_placeholder" from "ex., Celular, Trabalho, Casa"
to "Ex.: Celular, Trabalho, Casa" so both keys follow pt-BR capitalization and
punctuation conventions.
In `@packages/model-typings/src/models/IUsersModel.ts`:
- Line 408: The interface IUsersModel.setPhones currently requires phones to be
non-optional but UsersRaw.setPhones accepts IUser['phones'] (which is optional)
and treats undefined as a clear/unset; update the IUsersModel declaration for
setPhones to accept an optional phones parameter (e.g. phones?:
IUserPhoneNumber[] or phones: IUser['phones']) so the API contract matches
UsersRaw.setPhones and existing callers like saveUserProfile that only call when
Array.isArray(settings.phones) continue to work; alternatively, add a separate
clearPhones method if you want an explicit clear operation.
In `@packages/rest-typings/src/v1/users/UsersUpdateOwnBasicInfoParamsPOST.ts`:
- Line 16: The TypeScript type for the `phones` property (`IUserPhoneNumber[]`
in the `UsersUpdateOwnBasicInfoParamsPOST` definition) does not match the JSON
schema used for runtime validation (lines 63-76) because the schema forbids
extra props like `verified`; either narrow the TS type to a shape that excludes
`verified` (create a new type/alias used in this DTO instead of
`IUserPhoneNumber`) or relax the schema to allow `verified` (remove
`additionalProperties: false` or explicitly include `verified` in the schema
object), and update the `phones` property reference accordingly so compile-time
and runtime contracts align (adjust the interfaces/types and the JSON schema
block where `phones` is defined).
🪄 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: 05506d1e-daba-41f1-aa15-ac7eb89fac05
⛔ Files ignored due to path filters (1)
apps/meteor/client/components/PhoneNumberFieldList/__snapshots__/PhoneNumberFieldList.spec.tsx.snapis excluded by!**/*.snap
📒 Files selected for processing (35)
apps/meteor/app/api/server/v1/users.tsapps/meteor/app/lib/server/functions/getFullUserData.tsapps/meteor/app/lib/server/functions/saveUser/saveNewUser.tsapps/meteor/app/lib/server/functions/saveUser/saveUser.tsapps/meteor/app/utils/server/functions/getBaseUserFields.tsapps/meteor/client/components/PhoneNumberFieldList/PhoneNumberFieldList.spec.tsxapps/meteor/client/components/PhoneNumberFieldList/PhoneNumberFieldList.tsxapps/meteor/client/components/PhoneNumberFieldList/index.tsapps/meteor/client/components/UserInfo/UserInfo.tsxapps/meteor/client/lib/userData.tsapps/meteor/client/views/account/profile/AccountProfileForm.tsxapps/meteor/client/views/account/profile/getProfileInitialValues.tsapps/meteor/client/views/admin/users/AdminUserForm.tsxapps/meteor/client/views/admin/users/AdminUserInfoWithData.tsxapps/meteor/client/views/omnichannel/components/outboundMessage/components/TemplatePlaceholderSelector/hooks/useAgentSection.tsxapps/meteor/client/views/room/contextualBar/UserInfo/UserInfoWithData.tsxapps/meteor/server/methods/saveUserProfile.tsapps/meteor/tests/e2e/account-profile.spec.tsapps/meteor/tests/e2e/admin-users-phones.spec.tsapps/meteor/tests/e2e/page-objects/account-profile.tsapps/meteor/tests/e2e/page-objects/fragments/flextabs/edit-user-flextab.tsapps/meteor/tests/e2e/page-objects/fragments/flextabs/user-info-flextab.tsapps/meteor/tests/e2e/page-objects/fragments/index.tsapps/meteor/tests/e2e/page-objects/fragments/phone-number-field-list.tsapps/meteor/tests/end-to-end/api/users.tspackages/core-typings/src/IMeApiUser.tspackages/core-typings/src/IUser.tspackages/i18n/src/locales/en.i18n.jsonpackages/i18n/src/locales/pt-BR.i18n.jsonpackages/model-typings/src/models/IUsersModel.tspackages/models/src/models/Users.tspackages/rest-typings/src/v1/Ajv.tspackages/rest-typings/src/v1/users/UserCreateParamsPOST.tspackages/rest-typings/src/v1/users/UsersUpdateOwnBasicInfoParamsPOST.tspackages/rest-typings/src/v1/users/UsersUpdateParamsPOST.ts
📜 Review details
🧰 Additional context used
📓 Path-based instructions (5)
**/*.{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:
apps/meteor/tests/e2e/page-objects/fragments/index.tsapps/meteor/client/components/PhoneNumberFieldList/index.tsapps/meteor/app/lib/server/functions/saveUser/saveUser.tsapps/meteor/app/lib/server/functions/getFullUserData.tsapps/meteor/app/utils/server/functions/getBaseUserFields.tsapps/meteor/client/components/PhoneNumberFieldList/PhoneNumberFieldList.tsxapps/meteor/client/views/account/profile/getProfileInitialValues.tspackages/rest-typings/src/v1/users/UsersUpdateOwnBasicInfoParamsPOST.tsapps/meteor/tests/e2e/admin-users-phones.spec.tsapps/meteor/tests/e2e/page-objects/account-profile.tsapps/meteor/tests/e2e/page-objects/fragments/flextabs/user-info-flextab.tsapps/meteor/tests/e2e/page-objects/fragments/phone-number-field-list.tsapps/meteor/app/lib/server/functions/saveUser/saveNewUser.tsapps/meteor/tests/e2e/page-objects/fragments/flextabs/edit-user-flextab.tsapps/meteor/client/views/omnichannel/components/outboundMessage/components/TemplatePlaceholderSelector/hooks/useAgentSection.tsxpackages/core-typings/src/IUser.tspackages/models/src/models/Users.tspackages/rest-typings/src/v1/users/UsersUpdateParamsPOST.tsapps/meteor/tests/e2e/account-profile.spec.tsapps/meteor/client/components/PhoneNumberFieldList/PhoneNumberFieldList.spec.tsxapps/meteor/app/api/server/v1/users.tspackages/rest-typings/src/v1/Ajv.tsapps/meteor/client/views/admin/users/AdminUserForm.tsxapps/meteor/client/lib/userData.tsapps/meteor/tests/end-to-end/api/users.tspackages/rest-typings/src/v1/users/UserCreateParamsPOST.tspackages/model-typings/src/models/IUsersModel.tsapps/meteor/server/methods/saveUserProfile.tsapps/meteor/client/views/admin/users/AdminUserInfoWithData.tsxpackages/core-typings/src/IMeApiUser.tsapps/meteor/client/views/room/contextualBar/UserInfo/UserInfoWithData.tsxapps/meteor/client/views/account/profile/AccountProfileForm.tsxapps/meteor/client/components/UserInfo/UserInfo.tsx
apps/meteor/tests/e2e/page-objects/**/*.ts
📄 CodeRabbit inference engine (.cursor/rules/playwright.mdc)
Utilize existing page objects pattern from
apps/meteor/tests/e2e/page-objects/
Files:
apps/meteor/tests/e2e/page-objects/fragments/index.tsapps/meteor/tests/e2e/page-objects/account-profile.tsapps/meteor/tests/e2e/page-objects/fragments/flextabs/user-info-flextab.tsapps/meteor/tests/e2e/page-objects/fragments/phone-number-field-list.tsapps/meteor/tests/e2e/page-objects/fragments/flextabs/edit-user-flextab.ts
apps/meteor/tests/e2e/**/*.{ts,spec.ts}
📄 CodeRabbit inference engine (.cursor/rules/playwright.mdc)
apps/meteor/tests/e2e/**/*.{ts,spec.ts}: Store commonly used locators in variables/constants for reuse
Follow Page Object Model pattern consistently in Playwright tests
Files:
apps/meteor/tests/e2e/page-objects/fragments/index.tsapps/meteor/tests/e2e/admin-users-phones.spec.tsapps/meteor/tests/e2e/page-objects/account-profile.tsapps/meteor/tests/e2e/page-objects/fragments/flextabs/user-info-flextab.tsapps/meteor/tests/e2e/page-objects/fragments/phone-number-field-list.tsapps/meteor/tests/e2e/page-objects/fragments/flextabs/edit-user-flextab.tsapps/meteor/tests/e2e/account-profile.spec.ts
**/*.spec.ts
📄 CodeRabbit inference engine (.cursor/rules/playwright.mdc)
**/*.spec.ts: Use descriptive test names that clearly communicate expected behavior in Playwright tests
Use.spec.tsextension for test files (e.g.,login.spec.ts)
Files:
apps/meteor/tests/e2e/admin-users-phones.spec.tsapps/meteor/tests/e2e/account-profile.spec.ts
apps/meteor/tests/e2e/**/*.spec.ts
📄 CodeRabbit inference engine (.cursor/rules/playwright.mdc)
apps/meteor/tests/e2e/**/*.spec.ts: All test files must be created inapps/meteor/tests/e2e/directory
Avoid usingpage.locator()in Playwright tests - always prefer semantic locators such aspage.getByRole(),page.getByLabel(),page.getByText(), orpage.getByTitle()
Usetest.beforeAll()andtest.afterAll()for setup/teardown in Playwright tests
Usetest.step()for complex test scenarios to improve organization in Playwright tests
Group related tests in the same file
Utilize Playwright fixtures (test,page,expect) for consistency in test files
Prefer web-first assertions (toBeVisible,toHaveText, etc.) in Playwright tests
Useexpectmatchers for assertions (toEqual,toContain,toBeTruthy,toHaveLength, etc.) instead ofassertstatements in Playwright tests
Usepage.waitFor()with specific conditions instead of hardcoded timeouts in Playwright tests
Implement proper wait strategies for dynamic content in Playwright tests
Maintain test isolation between test cases in Playwright tests
Ensure clean state for each test execution in Playwright tests
Ensure tests run reliably in parallel without shared state conflicts
Files:
apps/meteor/tests/e2e/admin-users-phones.spec.tsapps/meteor/tests/e2e/account-profile.spec.ts
🧠 Learnings (16)
📚 Learning: 2025-12-16T17:29:40.430Z
Learnt from: gabriellsh
Repo: RocketChat/Rocket.Chat PR: 37834
File: apps/meteor/tests/e2e/page-objects/fragments/admin-flextab-emoji.ts:12-22
Timestamp: 2025-12-16T17:29:40.430Z
Learning: In all page-object files under apps/meteor/tests/e2e/page-objects/, import expect from ../../utils/test (Playwright's async expect) instead of from Jest. Jest's expect is synchronous and incompatible with web-first assertions like toBeVisible, which can cause TypeScript errors.
Applied to files:
apps/meteor/tests/e2e/page-objects/fragments/index.tsapps/meteor/tests/e2e/page-objects/account-profile.tsapps/meteor/tests/e2e/page-objects/fragments/flextabs/user-info-flextab.tsapps/meteor/tests/e2e/page-objects/fragments/phone-number-field-list.tsapps/meteor/tests/e2e/page-objects/fragments/flextabs/edit-user-flextab.ts
📚 Learning: 2026-02-24T19:39:42.247Z
Learnt from: juliajforesti
Repo: RocketChat/Rocket.Chat PR: 38493
File: apps/meteor/tests/e2e/page-objects/fragments/message.ts:7-7
Timestamp: 2026-02-24T19:39:42.247Z
Learning: In RocketChat e2e tests, avoid using data-qa attributes to locate elements. Prefer semantic locators such as getByRole, getByLabel, getByText, getByTitle and ARIA-based selectors. Apply this rule to all TypeScript files under apps/meteor/tests/e2e to improve test reliability, accessibility, and maintainability.
Applied to files:
apps/meteor/tests/e2e/page-objects/fragments/index.tsapps/meteor/tests/e2e/admin-users-phones.spec.tsapps/meteor/tests/e2e/page-objects/account-profile.tsapps/meteor/tests/e2e/page-objects/fragments/flextabs/user-info-flextab.tsapps/meteor/tests/e2e/page-objects/fragments/phone-number-field-list.tsapps/meteor/tests/e2e/page-objects/fragments/flextabs/edit-user-flextab.tsapps/meteor/tests/e2e/account-profile.spec.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 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:
apps/meteor/tests/e2e/page-objects/fragments/index.tsapps/meteor/client/components/PhoneNumberFieldList/index.tsapps/meteor/app/lib/server/functions/saveUser/saveUser.tsapps/meteor/app/lib/server/functions/getFullUserData.tsapps/meteor/app/utils/server/functions/getBaseUserFields.tsapps/meteor/client/views/account/profile/getProfileInitialValues.tspackages/rest-typings/src/v1/users/UsersUpdateOwnBasicInfoParamsPOST.tsapps/meteor/tests/e2e/admin-users-phones.spec.tsapps/meteor/tests/e2e/page-objects/account-profile.tsapps/meteor/tests/e2e/page-objects/fragments/flextabs/user-info-flextab.tsapps/meteor/tests/e2e/page-objects/fragments/phone-number-field-list.tsapps/meteor/app/lib/server/functions/saveUser/saveNewUser.tsapps/meteor/tests/e2e/page-objects/fragments/flextabs/edit-user-flextab.tspackages/core-typings/src/IUser.tspackages/models/src/models/Users.tspackages/rest-typings/src/v1/users/UsersUpdateParamsPOST.tsapps/meteor/tests/e2e/account-profile.spec.tsapps/meteor/app/api/server/v1/users.tspackages/rest-typings/src/v1/Ajv.tsapps/meteor/client/lib/userData.tsapps/meteor/tests/end-to-end/api/users.tspackages/rest-typings/src/v1/users/UserCreateParamsPOST.tspackages/model-typings/src/models/IUsersModel.tsapps/meteor/server/methods/saveUserProfile.tspackages/core-typings/src/IMeApiUser.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:
apps/meteor/tests/e2e/page-objects/fragments/index.tsapps/meteor/client/components/PhoneNumberFieldList/index.tsapps/meteor/app/lib/server/functions/saveUser/saveUser.tsapps/meteor/app/lib/server/functions/getFullUserData.tsapps/meteor/app/utils/server/functions/getBaseUserFields.tsapps/meteor/client/views/account/profile/getProfileInitialValues.tspackages/rest-typings/src/v1/users/UsersUpdateOwnBasicInfoParamsPOST.tsapps/meteor/tests/e2e/admin-users-phones.spec.tsapps/meteor/tests/e2e/page-objects/account-profile.tsapps/meteor/tests/e2e/page-objects/fragments/flextabs/user-info-flextab.tsapps/meteor/tests/e2e/page-objects/fragments/phone-number-field-list.tsapps/meteor/app/lib/server/functions/saveUser/saveNewUser.tsapps/meteor/tests/e2e/page-objects/fragments/flextabs/edit-user-flextab.tspackages/core-typings/src/IUser.tspackages/models/src/models/Users.tspackages/rest-typings/src/v1/users/UsersUpdateParamsPOST.tsapps/meteor/tests/e2e/account-profile.spec.tsapps/meteor/app/api/server/v1/users.tspackages/rest-typings/src/v1/Ajv.tsapps/meteor/client/lib/userData.tsapps/meteor/tests/end-to-end/api/users.tspackages/rest-typings/src/v1/users/UserCreateParamsPOST.tspackages/model-typings/src/models/IUsersModel.tsapps/meteor/server/methods/saveUserProfile.tspackages/core-typings/src/IMeApiUser.ts
📚 Learning: 2026-05-06T12:21:44.083Z
Learnt from: juliajforesti
Repo: RocketChat/Rocket.Chat PR: 40256
File: apps/meteor/client/components/CreateDiscussion/CreateDiscussion.tsx:121-149
Timestamp: 2026-05-06T12:21:44.083Z
Learning: Field wrappers in rocket.chat/fuselage-forms (Field, FieldLabel, FieldRow, FieldError, FieldHint) auto-create htmlFor/id associations, aria-describedby, and role="alert" for errors. Do not manually set htmlFor, id, aria-describedby, or role attributes when using these wrappers. This automatic wiring does not apply to plain rocket.chat/fuselage components, which require explicit ID wiring per the accessibility docs. In code reviews, prefer using fuselage-forms wrappers for form fields and verify there is no unnecessary manual ID/aria wiring in files that use these wrappers. If a component uses plain fuselage components, ensure proper id wiring as per docs.
Applied to files:
apps/meteor/tests/e2e/page-objects/fragments/index.tsapps/meteor/client/components/PhoneNumberFieldList/index.tsapps/meteor/app/lib/server/functions/saveUser/saveUser.tsapps/meteor/app/lib/server/functions/getFullUserData.tsapps/meteor/app/utils/server/functions/getBaseUserFields.tsapps/meteor/client/components/PhoneNumberFieldList/PhoneNumberFieldList.tsxapps/meteor/client/views/account/profile/getProfileInitialValues.tspackages/rest-typings/src/v1/users/UsersUpdateOwnBasicInfoParamsPOST.tsapps/meteor/tests/e2e/admin-users-phones.spec.tsapps/meteor/tests/e2e/page-objects/account-profile.tsapps/meteor/tests/e2e/page-objects/fragments/flextabs/user-info-flextab.tsapps/meteor/tests/e2e/page-objects/fragments/phone-number-field-list.tsapps/meteor/app/lib/server/functions/saveUser/saveNewUser.tsapps/meteor/tests/e2e/page-objects/fragments/flextabs/edit-user-flextab.tsapps/meteor/client/views/omnichannel/components/outboundMessage/components/TemplatePlaceholderSelector/hooks/useAgentSection.tsxpackages/core-typings/src/IUser.tspackages/models/src/models/Users.tspackages/rest-typings/src/v1/users/UsersUpdateParamsPOST.tsapps/meteor/tests/e2e/account-profile.spec.tsapps/meteor/client/components/PhoneNumberFieldList/PhoneNumberFieldList.spec.tsxapps/meteor/app/api/server/v1/users.tspackages/rest-typings/src/v1/Ajv.tsapps/meteor/client/views/admin/users/AdminUserForm.tsxapps/meteor/client/lib/userData.tsapps/meteor/tests/end-to-end/api/users.tspackages/rest-typings/src/v1/users/UserCreateParamsPOST.tspackages/model-typings/src/models/IUsersModel.tsapps/meteor/server/methods/saveUserProfile.tsapps/meteor/client/views/admin/users/AdminUserInfoWithData.tsxpackages/core-typings/src/IMeApiUser.tsapps/meteor/client/views/room/contextualBar/UserInfo/UserInfoWithData.tsxapps/meteor/client/views/account/profile/AccountProfileForm.tsxapps/meteor/client/components/UserInfo/UserInfo.tsx
📚 Learning: 2026-02-10T16:32:42.586Z
Learnt from: tassoevan
Repo: RocketChat/Rocket.Chat PR: 38528
File: apps/meteor/client/startup/roles.ts:14-14
Timestamp: 2026-02-10T16:32:42.586Z
Learning: In Rocket.Chat's Meteor client code, DDP streams use EJSON and Date fields arrive as Date objects; do not manually construct new Date() in stream handlers (for example, in sdk.stream()). Only REST API responses return plain JSON where dates are strings, so implement explicit conversion there if needed. Apply this guidance to all TypeScript files under apps/meteor/client to ensure consistent date handling in DDP streams and REST responses.
Applied to files:
apps/meteor/client/components/PhoneNumberFieldList/index.tsapps/meteor/client/views/account/profile/getProfileInitialValues.tsapps/meteor/client/lib/userData.ts
📚 Learning: 2026-05-11T20:30:35.265Z
Learnt from: tassoevan
Repo: RocketChat/Rocket.Chat PR: 40480
File: apps/meteor/client/meteor/startup/accounts.ts:59-61
Timestamp: 2026-05-11T20:30:35.265Z
Learning: In Rocket.Chat’s Meteor client code, when calling `dispatchToastMessage` with `{ type: 'error' }`, pass the raw caught error object as `message` without manual normalization. `dispatchToastMessage` is designed to accept `message: unknown` for error toasts, so avoid converting errors to strings (e.g., `String(error)`) or extracting `error.message` before passing them.
Applied to files:
apps/meteor/client/components/PhoneNumberFieldList/index.tsapps/meteor/client/views/account/profile/getProfileInitialValues.tsapps/meteor/client/lib/userData.ts
📚 Learning: 2026-03-27T14:52:56.865Z
Learnt from: dougfabris
Repo: RocketChat/Rocket.Chat PR: 39892
File: apps/meteor/client/views/room/contextualBar/Threads/Thread.tsx:150-155
Timestamp: 2026-03-27T14:52:56.865Z
Learning: In Rocket.Chat, there are two different `ModalBackdrop` components with different prop APIs. During review, confirm the import source: (1) `rocket.chat/fuselage` `ModalBackdrop` uses `ModalBackdropProps` based on `BoxProps` (so it supports `onClick` and other Box/DOM props) and does not have an `onDismiss` prop; (2) `rocket.chat/ui-client` `ModalBackdrop` uses a narrower props interface like `{ children?: ReactNode; onDismiss?: () => void }` and handles Escape keypress and outside mouse-up, and it does not forward arbitrary DOM props such as `onClick`. Flag mismatched props (e.g., `onDismiss` passed to the fuselage component or `onClick` passed to the ui-client component) and ensure the usage matches the correct component being imported.
Applied to files:
apps/meteor/client/components/PhoneNumberFieldList/PhoneNumberFieldList.tsxapps/meteor/client/views/omnichannel/components/outboundMessage/components/TemplatePlaceholderSelector/hooks/useAgentSection.tsxapps/meteor/client/components/PhoneNumberFieldList/PhoneNumberFieldList.spec.tsxapps/meteor/client/views/admin/users/AdminUserForm.tsxapps/meteor/client/views/admin/users/AdminUserInfoWithData.tsxapps/meteor/client/views/room/contextualBar/UserInfo/UserInfoWithData.tsxapps/meteor/client/views/account/profile/AccountProfileForm.tsxapps/meteor/client/components/UserInfo/UserInfo.tsx
📚 Learning: 2026-05-11T23:14:59.316Z
Learnt from: ricardogarim
Repo: RocketChat/Rocket.Chat PR: 40469
File: packages/rest-typings/src/v1/users.ts:337-337
Timestamp: 2026-05-11T23:14:59.316Z
Learning: In Rocket.Chat REST endpoint typings (e.g., packages/rest-typings/src/v1/users.ts and other rest-typings files), keep the established convention of deriving field types from the domain model (e.g., use IUser indexed access like IUser['statusExpiresAt']) rather than swapping individual fields to serialized primitives (like string) in an ad-hoc way. If a truly different “serialized” representation is needed, perform the refactor consistently across the codebase (not just a single endpoint/field) and ensure all related REST typings stay aligned with the shared serialization types.
Applied to files:
packages/rest-typings/src/v1/users/UsersUpdateOwnBasicInfoParamsPOST.tspackages/rest-typings/src/v1/users/UsersUpdateParamsPOST.tspackages/rest-typings/src/v1/Ajv.tspackages/rest-typings/src/v1/users/UserCreateParamsPOST.ts
📚 Learning: 2026-02-24T19:22:48.358Z
Learnt from: juliajforesti
Repo: RocketChat/Rocket.Chat PR: 38493
File: apps/meteor/tests/e2e/omnichannel/omnichannel-send-pdf-transcript.spec.ts:66-67
Timestamp: 2026-02-24T19:22:48.358Z
Learning: In Playwright end-to-end tests (e.g., under apps/meteor/tests/e2e/...), prefer locating elements by translated text (getByText) and ARIA roles (getByRole) over data-qa attributes. If translation values change, update the corresponding test locators accordingly. Never use data-qa locators. This guideline applies to all Playwright e2e test specs in the repository and helps keep tests robust to UI text changes and accessible semantics.
Applied to files:
apps/meteor/tests/e2e/admin-users-phones.spec.tsapps/meteor/tests/e2e/account-profile.spec.ts
📚 Learning: 2026-03-06T18:10:15.268Z
Learnt from: tassoevan
Repo: RocketChat/Rocket.Chat PR: 39397
File: packages/gazzodown/src/code/CodeBlock.spec.tsx:47-68
Timestamp: 2026-03-06T18:10:15.268Z
Learning: In tests (especially those using testing-library/dom/jsdom) for Rocket.Chat components, the HTML <code> element has an implicit ARIA role of 'code'. Therefore, screen.getByRole('code') or screen.findByRole('code') will locate <code> elements even without a role attribute. Do not flag findByRole('code') as invalid in reviews; prefer using the implicit role instead of adding role="code" unless necessary for accessibility.
Applied to files:
apps/meteor/tests/e2e/admin-users-phones.spec.tsapps/meteor/tests/e2e/account-profile.spec.tsapps/meteor/client/components/PhoneNumberFieldList/PhoneNumberFieldList.spec.tsx
📚 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/users.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/users.ts
📚 Learning: 2026-03-15T14:31:25.380Z
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:25.380Z
Learning: Do not flag this type/schema misalignment in the OpenAPI/migration review for apps/meteor/app/api/server/v1/users.ts. The UserCreateParamsPOST type intentionally uses non-optional fields: fields: string and settings?: IUserSettings without an AJV schema entry, carried over from the original rest-typings (PR `#39647`). Treat this as a known pre-existing divergence and document it as a separate follow-up fix; do not block or mark it as a review issue during the migration.
Applied to files:
apps/meteor/app/api/server/v1/users.ts
📚 Learning: 2026-03-16T23:33:11.443Z
Learnt from: amitb0ra
Repo: RocketChat/Rocket.Chat PR: 39676
File: apps/meteor/app/api/server/v1/users.ts:862-869
Timestamp: 2026-03-16T23:33:11.443Z
Learning: In rockets OpenAPI/AJV migration reviews for RocketChat/Rocket.Chat, when reviewing migrations that involve apps/meteor/app/api/server/v1/users.ts, do not require or flag a missing query AJV schema for the fields consumed by parseJsonQuery() (i.e., fields, sort, query) as part of this endpoint's migration PR. The addition of global query-param schemas for parseJsonQuery() usage is a cross-cutting concern and out of scope for individual endpoint migrations. Only flag violations related to the specific scope of the migration, not the absence of a query schema for parseJsonQuery() in this file.
Applied to files:
apps/meteor/app/api/server/v1/users.ts
📚 Learning: 2026-03-09T18:39:14.020Z
Learnt from: Harxhit
Repo: RocketChat/Rocket.Chat PR: 39476
File: apps/meteor/server/methods/addAllUserToRoom.ts:0-0
Timestamp: 2026-03-09T18:39:14.020Z
Learning: When implementing batch processing in server methods, favor a single data pass to collect both the items and any derived fields needed for validation. Use the same dataset for both validation and processing to avoid races between validation and execution, and document the approach in code comments. Apply this pattern to similar Meteor Rocket.Chat server methods under apps/meteor/server/methods to prevent race conditions and ensure consistent batch behavior.
Applied to files:
apps/meteor/server/methods/saveUserProfile.ts
🪛 ast-grep (0.42.3)
apps/meteor/tests/e2e/page-objects/fragments/phone-number-field-list.ts
[warning] 14-14: Regular expression constructed from variable input detected. This can lead to Regular Expression Denial of Service (ReDoS) attacks if the variable contains malicious patterns. Use libraries like 'recheck' to validate regex safety or use static patterns.
Context: new RegExp(Label for phone.*${index + 1})
Note: [CWE-1333] Inefficient Regular Expression Complexity [REFERENCES]
- https://owasp.org/www-community/attacks/Regular_expression_Denial_of_Service_-_ReDoS
- https://cwe.mitre.org/data/definitions/1333.html
(regexp-from-variable)
🔇 Additional comments (28)
packages/rest-typings/src/v1/users/UserCreateParamsPOST.ts (1)
1-1: LGTM!Also applies to: 23-23, 48-62
packages/rest-typings/src/v1/users/UsersUpdateParamsPOST.ts (1)
1-1: LGTM!Also applies to: 26-26, 111-125
apps/meteor/app/api/server/v1/users.ts (1)
204-204: LGTM!packages/core-typings/src/IUser.ts (2)
155-160: LGTM!
211-215: LGTM!packages/core-typings/src/IMeApiUser.ts (1)
28-28: LGTM!packages/models/src/models/Users.ts (1)
3057-3060: LGTM!packages/rest-typings/src/v1/Ajv.ts (1)
28-28: LGTM!Also applies to: 34-34
apps/meteor/app/lib/server/functions/saveUser/saveUser.ts (2)
57-57: LGTM!
186-192: ⚖️ Poor tradeoffDocument/guard phone
verifiedupdates insaveUser
saveUserProfilestripsverifiedfrom each phone before callingUsers.setPhones(...)(apps/meteor/server/methods/saveUserProfile.ts around line 125).saveUserupdatesphonesfromuserData.phoneswithout removingverified(apps/meteor/app/lib/server/functions/saveUser/saveUser.ts lines 186-192).
EnsuresaveUseris restricted to callers allowed to set phone verification state (or stripverifiedthere as well) and document the intended security model.apps/meteor/app/lib/server/functions/saveUser/saveNewUser.ts (1)
58-60: LGTM!apps/meteor/server/methods/saveUserProfile.ts (2)
2-2: LGTM!Also applies to: 37-37, 228-228, 248-248
122-131: LGTM!apps/meteor/app/lib/server/functions/getFullUserData.ts (1)
31-31: LGTM!apps/meteor/app/utils/server/functions/getBaseUserFields.ts (1)
10-10: LGTM!apps/meteor/client/lib/userData.ts (1)
18-18: LGTM!Also applies to: 92-92, 165-166
apps/meteor/client/components/UserInfo/UserInfo.tsx (1)
27-27: LGTM!Also applies to: 39-39, 68-68
apps/meteor/client/views/admin/users/AdminUserInfoWithData.tsx (1)
59-60: LGTM!Also applies to: 75-76, 86-86
apps/meteor/client/views/room/contextualBar/UserInfo/UserInfoWithData.tsx (1)
65-66: LGTM!Also applies to: 73-74, 87-87
apps/meteor/client/views/omnichannel/components/outboundMessage/components/TemplatePlaceholderSelector/hooks/useAgentSection.tsx (1)
32-37: LGTM!apps/meteor/client/components/PhoneNumberFieldList/PhoneNumberFieldList.tsx (1)
1-44: LGTM!Also applies to: 52-105
apps/meteor/client/components/PhoneNumberFieldList/index.ts (1)
1-2: LGTM!apps/meteor/client/components/PhoneNumberFieldList/PhoneNumberFieldList.spec.tsx (1)
1-179: LGTM!apps/meteor/client/views/account/profile/AccountProfileForm.tsx (1)
19-19: LGTM!Also applies to: 24-24, 102-141, 311-326
apps/meteor/client/views/account/profile/getProfileInitialValues.ts (1)
1-1: LGTM!Also applies to: 16-16, 30-30
apps/meteor/client/views/admin/users/AdminUserForm.tsx (1)
1-1: LGTM!Also applies to: 34-34, 43-43, 58-61, 89-89, 129-129, 533-547
packages/i18n/src/locales/en.i18n.json (1)
2778-2778: LGTM!Also applies to: 3038-3038, 4170-4171, 4492-4492
packages/i18n/src/locales/pt-BR.i18n.json (1)
2764-2764: LGTM!Also applies to: 3012-3012, 4465-4465
There was a problem hiding this comment.
4 issues found across 40 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="apps/meteor/client/views/account/profile/AccountProfileForm.tsx">
<violation number="1" location="apps/meteor/client/views/account/profile/AccountProfileForm.tsx:320">
P3: Passing `useFieldArray().fields` as value data causes stale phone labels in accessibility text (remove button `aria-label` won’t track edits).</violation>
</file>
<file name="apps/meteor/client/components/PhoneNumberFieldList/PhoneNumberFieldList.tsx">
<violation number="1" location="apps/meteor/client/components/PhoneNumberFieldList/PhoneNumberFieldList.tsx:8">
P2: `E164_PHONE_REGEX` allows numbers without a leading `+`, so non-E.164 values are accepted as valid.</violation>
</file>
<file name="apps/meteor/client/lib/userData.ts">
<violation number="1" location="apps/meteor/client/lib/userData.ts:165">
P2: `phones` is assigned unconditionally and can clear existing phone data when `/v1/me` does not include the field.</violation>
</file>
<file name="apps/meteor/server/methods/saveUserProfile.ts">
<violation number="1" location="apps/meteor/server/methods/saveUserProfile.ts:125">
P2: `phones` items are not validated before object destructuring, which can throw on malformed array entries.</violation>
</file>
Reply with feedback, questions, or to request a fix.
Re-trigger cubic
| import { Controller } from 'react-hook-form'; | ||
| import { useTranslation } from 'react-i18next'; | ||
|
|
||
| const E164_PHONE_REGEX = /^\+?[1-9]\d{1,14}$/; |
There was a problem hiding this comment.
P2: E164_PHONE_REGEX allows numbers without a leading +, so non-E.164 values are accepted as valid.
Prompt for AI agents
Check if this issue is valid — if so, understand the root cause and fix it. At apps/meteor/client/components/PhoneNumberFieldList/PhoneNumberFieldList.tsx, line 8:
<comment>`E164_PHONE_REGEX` allows numbers without a leading `+`, so non-E.164 values are accepted as valid.</comment>
<file context>
@@ -0,0 +1,98 @@
+import { Controller } from 'react-hook-form';
+import { useTranslation } from 'react-i18next';
+
+const E164_PHONE_REGEX = /^\+?[1-9]\d{1,14}$/;
+const MAX_PHONE_NUMBER_LABEL_LENGTH = 50;
+
</file context>
| const E164_PHONE_REGEX = /^\+?[1-9]\d{1,14}$/; | |
| const E164_PHONE_REGEX = /^\+[1-9]\d{1,14}$/; |
| ldap: Boolean(ldap), | ||
| createdAt: meFields.createdAt != null ? new Date(meFields.createdAt) : (existingUser?.createdAt ?? new Date()), | ||
| _updatedAt: new Date(meFields._updatedAt ?? existingUser?._updatedAt ?? Date.now()), | ||
| phones, |
There was a problem hiding this comment.
P2: phones is assigned unconditionally and can clear existing phone data when /v1/me does not include the field.
Prompt for AI agents
Check if this issue is valid — if so, understand the root cause and fix it. At apps/meteor/client/lib/userData.ts, line 165:
<comment>`phones` is assigned unconditionally and can clear existing phone data when `/v1/me` does not include the field.</comment>
<file context>
@@ -161,6 +162,7 @@ export const synchronizeUserData = async (uid: IUser['_id']): Promise<RawUserDat
ldap: Boolean(ldap),
createdAt: meFields.createdAt != null ? new Date(meFields.createdAt) : (existingUser?.createdAt ?? new Date()),
_updatedAt: new Date(meFields._updatedAt ?? existingUser?._updatedAt ?? Date.now()),
+ phones,
} as IUser);
}
</file context>
| phones, | |
| phones: phones ?? existingUser?.phones, |
| if (Array.isArray(settings.phones)) { | ||
| await Users.setPhones( | ||
| user._id, | ||
| settings.phones.map(({ verified: _, ...phone }) => phone), |
There was a problem hiding this comment.
P2: phones items are not validated before object destructuring, which can throw on malformed array entries.
Prompt for AI agents
Check if this issue is valid — if so, understand the root cause and fix it. At apps/meteor/server/methods/saveUserProfile.ts, line 125:
<comment>`phones` items are not validated before object destructuring, which can throw on malformed array entries.</comment>
<file context>
@@ -118,6 +119,17 @@ async function saveUserProfile(
+ if (Array.isArray(settings.phones)) {
+ await Users.setPhones(
+ user._id,
+ settings.phones.map(({ verified: _, ...phone }) => phone),
+ );
+
</file context>
| settings.phones.map(({ verified: _, ...phone }) => phone), | |
| settings.phones.map((entry) => { | |
| if (!entry || typeof entry !== 'object' || typeof entry.number !== 'string') { | |
| throw new Meteor.Error('error-invalid-field', 'phones', { | |
| method: 'saveUserProfile', | |
| }); | |
| } | |
| const { verified: _, ...phone } = entry; | |
| return phone; | |
| }), |
| <PhoneNumberFieldList | ||
| control={control} | ||
| name='phones' | ||
| phones={phoneFields} |
There was a problem hiding this comment.
P3: Passing useFieldArray().fields as value data causes stale phone labels in accessibility text (remove button aria-label won’t track edits).
Prompt for AI agents
Check if this issue is valid — if so, understand the root cause and fix it. At apps/meteor/client/views/account/profile/AccountProfileForm.tsx, line 320:
<comment>Passing `useFieldArray().fields` as value data causes stale phone labels in accessibility text (remove button `aria-label` won’t track edits).</comment>
<file context>
@@ -290,6 +308,22 @@ const AccountProfileForm = (props: AllHTMLAttributes<HTMLFormElement>): ReactEle
+ <PhoneNumberFieldList
+ control={control}
+ name='phones'
+ phones={phoneFields}
+ onAddPhone={appendPhone}
+ onRemovePhone={removePhone}
</file context>
Proposed changes (including videos or screenshots)
This PR adds support for multiple phone numbers per user across the application, replacing the previous single
phonefield with a newphonesarray.Backend changes
phonesfield to the user model and updatedSaveUserDataaccordingly.phonesarray.phonesin user data query responses.Frontend changes
PhoneNumberFieldListcomponent to manage multiple phone numbers in forms, including validation and accessibility support.UserInfoto display all phone numbers with their labels instead of a single phone field.Tests
PhoneNumberFieldList, covering rendering, accessibility, interactions, validation, and snapshots.These changes provide a more flexible way to manage user contact information while keeping the experience consistent across the application.
Issue(s)
Steps to test or reproduce
Further comments
Summary by CodeRabbit
New Features
Tests