refactor: index token string via tokenValue/tokenType pair - #41382
refactor: index token string via tokenValue/tokenType pair#41382ricardogarim wants to merge 3 commits into
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 |
🦋 Changeset detectedLatest commit: fc59d28 The changes in this PR will be included in the next version bump. This PR includes changesets to release 6 packages
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 |
WalkthroughPush-token records now use flat ChangesPush-token normalization
Estimated code review effort: 4 (Complex) | ~45 minutes Sequence Diagram(s)sequenceDiagram
participant PushTokenAPI
participant PushService
participant TokenManagement
participant PushTokenModel
PushTokenAPI->>PushService: Submit RegisterPushTokenInput
PushService->>TokenManagement: Register tokenType and tokenValue
TokenManagement->>PushTokenModel: Insert or refresh token document
TokenManagement->>PushTokenModel: Remove duplicate tokens
PushService->>TokenManagement: Register optional VoIP token separately
PushTokenAPI-->>PushTokenAPI: Return tokenType and tokenValue
sequenceDiagram
participant Notification
participant NativeDelivery
participant GatewayDelivery
participant APN
participant FCM
Notification->>NativeDelivery: Deliver normalized push token
NativeDelivery->>APN: Send tokenValue for APN or VoIP
NativeDelivery->>FCM: Send tokenValue for GCM
Notification->>GatewayDelivery: Deliver normalized push token
GatewayDelivery->>APN: Send tokenValue for APN or VoIP
GatewayDelivery->>FCM: Send tokenValue for GCM
Possibly related PRs
Suggested labels: Suggested reviewers: 🚥 Pre-merge checks | ✅ 4 | ❌ 1❌ Failed checks (1 warning)
✅ Passed checks (4 passed)
✨ Finishing Touches 💡 1🛠️ Fix failing CI checks 💡
Warning Review ran into problems🔥 ProblemsErrors were encountered while retrieving linked issues. Errors (1)
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: 4
Caution
Some comments are outside the diff and can’t be posted inline due to platform limitations.
⚠️ Outside diff range comments (1)
apps/meteor/server/api/v1/push.ts (1)
114-146: 🗄️ Data Integrity & Integration | 🟠 Major | ⚡ Quick winRequire the normalized fields in the response schema.
PushTokenResultrequires these fields, but AJV currently accepts an emptyresultobject. Add a nestedrequiredarray so runtime validation enforces the breaking API contract.Proposed fix
result: { type: 'object', description: 'The updated token data for this device', + required: ['_id', 'tokenType', 'tokenValue', 'appName', 'userId', 'enabled', 'createdAt', '_updatedAt'], properties: {🤖 Prompt for 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. In `@apps/meteor/server/api/v1/push.ts` around lines 114 - 146, Update the response schema’s result object in the push endpoint to include a required array listing every field required by PushTokenResult: _id, tokenType, tokenValue, appName, userId, enabled, createdAt, and _updatedAt. Preserve the existing property definitions and additionalProperties restriction.
🧹 Nitpick comments (3)
apps/meteor/server/services/push/lib/registerPushToken.ts (1)
50-50: 📐 Maintainability & Code Quality | 🔵 Trivial | ⚡ Quick winRemove the implementation comment.
The surrounding
tokenTypeargument already expresses the deduplication scope. As per coding guidelines, “Avoid code comments in the implementation.”🤖 Prompt for 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. In `@apps/meteor/server/services/push/lib/registerPushToken.ts` at line 50, Remove the implementation comment above the token deduplication logic in registerPushToken, leaving the existing tokenType-based behavior and surrounding code unchanged.Source: Coding guidelines
apps/meteor/tests/unit/server/lib/notifications/push/push.spec.ts (1)
2-2: 📐 Maintainability & Code Quality | 🔵 Trivial | ⚡ Quick winImport
IPushTokenfrom the package root.
@rocket.chat/core-typingsre-exportsIPushToken, so this test should avoid the internalsrc/IPushTokenpath.Proposed fix
-import type { IPushToken } from '`@rocket.chat/core-typings/src/IPushToken`'; +import type { IPushToken } from '`@rocket.chat/core-typings`';🤖 Prompt for 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. In `@apps/meteor/tests/unit/server/lib/notifications/push/push.spec.ts` at line 2, Update the IPushToken import in the push notification test to use the `@rocket.chat/core-typings` package root instead of its internal src/IPushToken path, preserving the existing type usage.apps/meteor/server/startup/migrations/v336.ts (1)
11-11: 📐 Maintainability & Code Quality | 🔵 Trivial | 💤 Low valueRemove the implementation comment.
As per coding guidelines, “Avoid code comments in the implementation.”
🤖 Prompt for 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. In `@apps/meteor/server/startup/migrations/v336.ts` at line 11, Remove the implementation comment describing the VOIP token migration, while leaving the migration logic and its idempotency behavior unchanged.Source: Coding guidelines
🤖 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/server/services/push/lib/findDocumentToUpdate.ts`:
- Around line 12-13: Update the lookup in findDocumentToUpdate to include
data.tokenType alongside data.tokenValue and data.appName, and use the lookup
contract { tokenType, tokenValue, appName } when calling
findOneByTokenAndAppName. Ensure the underlying method and its callers accept
and match tokenType so APN and VoIP records remain distinct.
In `@apps/meteor/server/startup/migrations/v336.ts`:
- Around line 31-39: The migration updates in v336 must preserve both APN and
GCM values from legacy documents containing both token properties. Before the
existing APN/GCM updates unset token, split dual-platform records into
deterministic separate documents, each retaining one platform token, then run
the platform-specific updates without losing the counterpart.
In `@packages/core-typings/src/IPushToken.ts`:
- Line 10: Update the PushTokenTarget type to make its union branches mutually
exclusive by adding an optional never-typed opposite property to each branch:
APN targets must reject gcm, and GCM targets must reject apn. Keep the existing
string requirements for the selected target property.
In `@packages/model-typings/src/models/IPushTokenModel.ts`:
- Line 10: Update findOneByTokenAndAppName to accept tokenType as part of the
lookup identity, then propagate it through the model query and the first token
deduplication predicate so standard and VoIP registrations with the same value
remain separate.
---
Outside diff comments:
In `@apps/meteor/server/api/v1/push.ts`:
- Around line 114-146: Update the response schema’s result object in the push
endpoint to include a required array listing every field required by
PushTokenResult: _id, tokenType, tokenValue, appName, userId, enabled,
createdAt, and _updatedAt. Preserve the existing property definitions and
additionalProperties restriction.
---
Nitpick comments:
In `@apps/meteor/server/services/push/lib/registerPushToken.ts`:
- Line 50: Remove the implementation comment above the token deduplication logic
in registerPushToken, leaving the existing tokenType-based behavior and
surrounding code unchanged.
In `@apps/meteor/server/startup/migrations/v336.ts`:
- Line 11: Remove the implementation comment describing the VOIP token
migration, while leaving the migration logic and its idempotency behavior
unchanged.
In `@apps/meteor/tests/unit/server/lib/notifications/push/push.spec.ts`:
- Line 2: Update the IPushToken import in the push notification test to use the
`@rocket.chat/core-typings` package root instead of its internal src/IPushToken
path, preserving the existing type usage.
🪄 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: 68b69c3b-1fda-4e49-9e49-934060c6b5ea
📒 Files selected for processing (15)
.changeset/fancy-zebras-go.mdapps/meteor/server/api/v1/push.tsapps/meteor/server/lib/notifications/push/push.tsapps/meteor/server/meteor-methods/platform/push.tsapps/meteor/server/services/push/lib/findDocumentToUpdate.tsapps/meteor/server/services/push/lib/registerPushToken.tsapps/meteor/server/services/push/service.tsapps/meteor/server/startup/migrations/index.tsapps/meteor/server/startup/migrations/v336.tsapps/meteor/tests/end-to-end/api/push.tsapps/meteor/tests/unit/server/lib/notifications/push/push.spec.tspackages/core-services/src/types/IPushService.tspackages/core-typings/src/IPushToken.tspackages/model-typings/src/models/IPushTokenModel.tspackages/models/src/models/PushToken.ts
📜 Review details
⏰ Context from checks skipped due to timeout. (2)
- GitHub Check: 📦 Build Packages
- GitHub Check: CodeQL-Build
🧰 Additional context used
📓 Path-based instructions (2)
**/*.{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/server/startup/migrations/index.tsapps/meteor/server/startup/migrations/v336.tspackages/core-services/src/types/IPushService.tsapps/meteor/tests/end-to-end/api/push.tsapps/meteor/server/meteor-methods/platform/push.tsapps/meteor/server/services/push/lib/findDocumentToUpdate.tsapps/meteor/server/services/push/lib/registerPushToken.tsapps/meteor/tests/unit/server/lib/notifications/push/push.spec.tspackages/model-typings/src/models/IPushTokenModel.tsapps/meteor/server/services/push/service.tspackages/core-typings/src/IPushToken.tsapps/meteor/server/lib/notifications/push/push.tsapps/meteor/server/api/v1/push.tspackages/models/src/models/PushToken.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/unit/server/lib/notifications/push/push.spec.ts
🧠 Learnings (6)
📚 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/server/startup/migrations/index.tsapps/meteor/server/startup/migrations/v336.tspackages/core-services/src/types/IPushService.tsapps/meteor/tests/end-to-end/api/push.tsapps/meteor/server/meteor-methods/platform/push.tsapps/meteor/server/services/push/lib/findDocumentToUpdate.tsapps/meteor/server/services/push/lib/registerPushToken.tsapps/meteor/tests/unit/server/lib/notifications/push/push.spec.tspackages/model-typings/src/models/IPushTokenModel.tsapps/meteor/server/services/push/service.tspackages/core-typings/src/IPushToken.tsapps/meteor/server/lib/notifications/push/push.tsapps/meteor/server/api/v1/push.tspackages/models/src/models/PushToken.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/server/startup/migrations/index.tsapps/meteor/server/startup/migrations/v336.tspackages/core-services/src/types/IPushService.tsapps/meteor/tests/end-to-end/api/push.tsapps/meteor/server/meteor-methods/platform/push.tsapps/meteor/server/services/push/lib/findDocumentToUpdate.tsapps/meteor/server/services/push/lib/registerPushToken.tsapps/meteor/tests/unit/server/lib/notifications/push/push.spec.tspackages/model-typings/src/models/IPushTokenModel.tsapps/meteor/server/services/push/service.tspackages/core-typings/src/IPushToken.tsapps/meteor/server/lib/notifications/push/push.tsapps/meteor/server/api/v1/push.tspackages/models/src/models/PushToken.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/server/startup/migrations/index.tsapps/meteor/server/startup/migrations/v336.tspackages/core-services/src/types/IPushService.tsapps/meteor/tests/end-to-end/api/push.tsapps/meteor/server/meteor-methods/platform/push.tsapps/meteor/server/services/push/lib/findDocumentToUpdate.tsapps/meteor/server/services/push/lib/registerPushToken.tsapps/meteor/tests/unit/server/lib/notifications/push/push.spec.tspackages/model-typings/src/models/IPushTokenModel.tsapps/meteor/server/services/push/service.tspackages/core-typings/src/IPushToken.tsapps/meteor/server/lib/notifications/push/push.tsapps/meteor/server/api/v1/push.tspackages/models/src/models/PushToken.ts
📚 Learning: 2026-03-16T21:50:37.589Z
Learnt from: amitb0ra
Repo: RocketChat/Rocket.Chat PR: 39676
File: .changeset/migrate-users-register-openapi.md:3-3
Timestamp: 2026-03-16T21:50:37.589Z
Learning: For changes related to OpenAPI migrations in Rocket.Chat/OpenAPI, when removing endpoint types and validators from rocket.chat/rest-typings (e.g., UserRegisterParamsPOST, /v1/users.register) document this as a minor changeset (not breaking) per RocketChat/Rocket.Chat-Open-API#150 Rule 7. Note that the endpoint type is re-exposed via a module augmentation .d.ts in the consuming package (e.g., packages/web-ui-registration/src/users-register.d.ts). In reviews, ensure the changeset clearly states: this is a non-breaking change, the major version should not be bumped, and the changeset reflects a minor version bump. Do not treat this as a breaking change during OpenAPI migrations.
Applied to files:
.changeset/fancy-zebras-go.md
📚 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/unit/server/lib/notifications/push/push.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/unit/server/lib/notifications/push/push.spec.ts
🔇 Additional comments (15)
apps/meteor/server/services/push/lib/registerPushToken.ts (1)
8-20: LGTM!Also applies to: 29-43, 51-62
apps/meteor/server/services/push/service.ts (1)
3-6: LGTM!Also applies to: 34-45
apps/meteor/server/api/v1/push.ts (1)
3-3: LGTM!Also applies to: 81-98, 158-175
.changeset/fancy-zebras-go.md (1)
1-9: LGTM!apps/meteor/tests/end-to-end/api/push.ts (1)
24-24: LGTM!Also applies to: 41-41
apps/meteor/server/lib/notifications/push/push.ts (1)
175-179: LGTM!Also applies to: 191-233, 350-370, 405-405
apps/meteor/tests/unit/server/lib/notifications/push/push.spec.ts (1)
3-17: LGTM!Also applies to: 117-176
packages/models/src/models/PushToken.ts (2)
81-82: Covered by the token identity contract finding inIPushTokenModel.Also applies to: 92-97
17-79: LGTM!Also applies to: 108-116
packages/core-typings/src/IPushToken.ts (1)
8-8: LGTM!Also applies to: 12-30
packages/model-typings/src/models/IPushTokenModel.ts (1)
19-32: LGTM!packages/core-services/src/types/IPushService.ts (1)
1-6: LGTM!apps/meteor/server/meteor-methods/platform/push.ts (1)
2-2: LGTM!Also applies to: 15-15
apps/meteor/server/startup/migrations/index.ts (1)
44-44: LGTM!apps/meteor/server/startup/migrations/v336.ts (1)
1-10: LGTM!Also applies to: 12-30, 41-46
Codecov Report❌ Patch coverage is Additional details and impacted files@@ Coverage Diff @@
## release-9.0.0 #41382 +/- ##
=================================================
- Coverage 68.84% 68.83% -0.01%
=================================================
Files 4134 4135 +1
Lines 158195 158203 +8
Branches 28021 28020 -1
=================================================
- Hits 108906 108898 -8
- Misses 44145 44160 +15
- Partials 5144 5145 +1
Flags with carried forward coverage won't be shown. Click here to find out more. 🚀 New features to boost your workflow:
|
0e9fccb to
44b5d45
Compare
There was a problem hiding this comment.
All reported issues were addressed across 15 files
Reply with feedback, questions, or to request a fix.
Re-trigger cubic
44b5d45 to
bd0b525
Compare
b45114b to
bed87f2
Compare
011f7fb to
7621bfc
Compare
bd0b525 to
98465e6
Compare
|
Note GitHub couldn't provide a complete incremental comparison for this pull request, so CodeRabbit is performing a full review instead. This review may take a little longer. |
There was a problem hiding this comment.
🧹 Nitpick comments (1)
apps/meteor/server/startup/migrations/v337.ts (1)
11-11: 📐 Maintainability & Code Quality | 🔵 Trivial | 💤 Low valueRemove implementation comments.
apps/meteor/server/startup/migrations/v337.ts#L11-L11: Remove the migration comment.apps/meteor/server/services/push/tokenManagement/registerPushToken.ts#L50-L50: Remove the deduplication comment.As per coding guidelines, “Avoid code comments in the implementation.”
🤖 Prompt for 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. In `@apps/meteor/server/startup/migrations/v337.ts` at line 11, Remove the implementation comment in apps/meteor/server/startup/migrations/v337.ts at lines 11-11, and remove the deduplication comment in apps/meteor/server/services/push/tokenManagement/registerPushToken.ts at lines 50-50. Do not alter the surrounding migration or token-registration behavior.Source: Coding guidelines
🤖 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.
Nitpick comments:
In `@apps/meteor/server/startup/migrations/v337.ts`:
- Line 11: Remove the implementation comment in
apps/meteor/server/startup/migrations/v337.ts at lines 11-11, and remove the
deduplication comment in
apps/meteor/server/services/push/tokenManagement/registerPushToken.ts at lines
50-50. Do not alter the surrounding migration or token-registration behavior.
ℹ️ Review info
⚙️ Run configuration
Configuration used: Organization UI
Review profile: CHILL
Plan: Pro Plus
Run ID: 02d12d4b-1bca-4601-9aff-93b7d4567bd7
📒 Files selected for processing (15)
.changeset/fancy-zebras-go.mdapps/meteor/server/api/v1/push.tsapps/meteor/server/lib/notifications/push/push.tsapps/meteor/server/meteor-methods/platform/push.tsapps/meteor/server/services/push/service.tsapps/meteor/server/services/push/tokenManagement/findDocumentToUpdate.tsapps/meteor/server/services/push/tokenManagement/registerPushToken.tsapps/meteor/server/startup/migrations/index.tsapps/meteor/server/startup/migrations/v337.tsapps/meteor/tests/end-to-end/api/push.tsapps/meteor/tests/unit/server/lib/notifications/push/push.spec.tspackages/core-services/src/types/IPushService.tspackages/core-typings/src/IPushToken.tspackages/model-typings/src/models/IPushTokenModel.tspackages/models/src/models/PushToken.ts
🚧 Files skipped from review as they are similar to previous changes (11)
- apps/meteor/tests/end-to-end/api/push.ts
- apps/meteor/server/startup/migrations/index.ts
- apps/meteor/server/meteor-methods/platform/push.ts
- packages/core-services/src/types/IPushService.ts
- apps/meteor/tests/unit/server/lib/notifications/push/push.spec.ts
- apps/meteor/server/api/v1/push.ts
- packages/core-typings/src/IPushToken.ts
- .changeset/fancy-zebras-go.md
- apps/meteor/server/services/push/service.ts
- apps/meteor/server/lib/notifications/push/push.ts
- packages/models/src/models/PushToken.ts
📜 Review details
⏰ Context from checks skipped due to timeout. (4)
- GitHub Check: 📦 Build Packages
- GitHub Check: Hacktron Security Check
- GitHub Check: CodeQL-Build
- GitHub Check: CodeQL-Build
⚠️ CI failures not shown inline (3)
GitHub Check: Dionisio QA: Some checks did not pass
Conclusion: failure
**Conclusion:** failure
### Steps
- ✅ **No merge conflicts**
- ❌ **QA assured** — This PR is missing the 'stat: QA assured' label
- ✅ **Mergeable**
- ✅ **Has milestone or project**
- ✅ **Valid PR title**
- ✅ **Correct target version**
GitHub Check: Dionisio QA: Some checks did not pass
Conclusion: failure
**Conclusion:** failure
### Steps
- ✅ **No merge conflicts**
- ❌ **QA assured** — This PR is missing the 'stat: QA assured' label
- ✅ **Mergeable**
- ✅ **Has milestone or project**
- ✅ **Valid PR title**
- ✅ **Correct target version**
GitHub Check: Dionisio QA: Some checks did not pass
Conclusion: failure
**Conclusion:** failure
### Steps
- ✅ **No merge conflicts**
- ❌ **QA assured** — This PR is missing the 'stat: QA assured' label
- ✅ **Mergeable**
- ✅ **Has milestone or project**
- ✅ **Valid PR title**
- ✅ **Correct target version**
🧰 Additional context used
📓 Path-based instructions (1)
**/*.{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/server/startup/migrations/v337.tsapps/meteor/server/services/push/tokenManagement/findDocumentToUpdate.tsapps/meteor/server/services/push/tokenManagement/registerPushToken.tspackages/model-typings/src/models/IPushTokenModel.ts
🧠 Learnings (5)
📚 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/server/startup/migrations/v337.tsapps/meteor/server/services/push/tokenManagement/findDocumentToUpdate.tsapps/meteor/server/services/push/tokenManagement/registerPushToken.tspackages/model-typings/src/models/IPushTokenModel.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/server/startup/migrations/v337.tsapps/meteor/server/services/push/tokenManagement/findDocumentToUpdate.tsapps/meteor/server/services/push/tokenManagement/registerPushToken.tspackages/model-typings/src/models/IPushTokenModel.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/server/startup/migrations/v337.tsapps/meteor/server/services/push/tokenManagement/findDocumentToUpdate.tsapps/meteor/server/services/push/tokenManagement/registerPushToken.tspackages/model-typings/src/models/IPushTokenModel.ts
📚 Learning: 2026-08-05T22:02:59.828Z
Learnt from: ricardogarim
Repo: RocketChat/Rocket.Chat PR: 41707
File: apps/meteor/server/hooks/messages/processThreads.ts:66-68
Timestamp: 2026-08-05T22:02:59.828Z
Learning: In Rocket.Chat Meteor server code, `callbacks.runAsync` returns its input item rather than the asynchronous callback promise. Callers of `afterReadMessages` must invoke `callbacks.runAsync` without awaiting it, keeping read-receipt I/O off the message-send path; this includes `apps/meteor/server/hooks/messages/processThreads.ts`.
Applied to files:
apps/meteor/server/startup/migrations/v337.tsapps/meteor/server/services/push/tokenManagement/findDocumentToUpdate.tsapps/meteor/server/services/push/tokenManagement/registerPushToken.ts
📚 Learning: 2026-07-15T01:31:50.632Z
Learnt from: ricardogarim
Repo: RocketChat/Rocket.Chat PR: 41382
File: packages/model-typings/src/models/IPushTokenModel.ts:10-10
Timestamp: 2026-07-15T01:31:50.632Z
Learning: In Rocket.Chat’s push-token model, APNs/GCM standard tokens and PushKit VoIP tokens use distinct, globally-unique token string values. As a result, when deduplicating/looking up tokens, key identity solely on `{ tokenValue, appName }` (e.g., for `findOneByTokenAndAppName`, `removeDuplicateTokens`) and do **not** include `tokenType` in the uniqueness criteria to avoid collisions between standard and VoIP tokens.
Applied to files:
packages/model-typings/src/models/IPushTokenModel.ts
🔇 Additional comments (4)
packages/model-typings/src/models/IPushTokenModel.ts (1)
10-10: LGTM!Also applies to: 19-32
apps/meteor/server/startup/migrations/v337.ts (1)
5-10: LGTM!Also applies to: 12-45
apps/meteor/server/services/push/tokenManagement/findDocumentToUpdate.ts (1)
12-13: LGTM!apps/meteor/server/services/push/tokenManagement/registerPushToken.ts (1)
7-21: LGTM!Also applies to: 31-48
98465e6 to
fc59d28
Compare
Proposed changes (including videos or screenshots)
The Push Token collection (
_raix_push_app_tokens) is queried by the device token string, but that value lived in one of three attributes (token.apn,token.gcm,voipToken) — so those queries had no index (a full collection scan ran on every failed-push cleanup). This flattens storage to a single, indexabletokenValue/tokenTypepair.token: { apn | gcm }object →tokenValue: string+tokenType: 'apn' | 'gcm' | 'voip'. ThevoipTokenfield is removed — a VoIP token is now a first-classtokenType: 'voip'in its own document (so a VoIP-capable iOS device becomes two documents).{ tokenValue },{ appName, tokenValue },{ tokenType }; dropped the now-meaningless{ appName, token }. Every token-string lookup is now index-backed.v336: flattens each legacy document; a coexistingvoipTokenis split into its own voip document with a deterministic_id(idempotent).tokenType(voip → APN with the.voiptopic; apn/gcm → regular). Registration writes two documents when avoipTokenis supplied.POST /v1/push.tokennow returns a flat{ tokenValue, tokenType }instead of the nested{ token: { apn|gcm } }. Request/input formats are unchanged.Issue(s)
Steps to test or reproduce
voipTokenviaPOST /v1/push.token.v336runs → legacy docs becometokenValue/tokenType, and each apn+voip doc splits into two (<id>and<id>_voip).POST /v1/push.tokenagain → the response is flattokenValue/tokenType.useVoipToken) to a user with both documents → each reaches only the correct token/topic.DELETE /v1/push.tokenwith a token string → the matching document is removed.Unit tests:
cd apps/meteor && yarn .testunit:server --grep "Push".Further comments
Why is VoIP now its own document?
On iOS a single app has two Apple push tokens — a standard APNs token and a separate PushKit VoIP token (delivered via APNs with a
.voiptopic). VoIP tokens are iOS-only — Android/FCM has no separate VoIP token (it uses high-priority FCM messages on the same token), sogcmnever carries one. Because both belong to the same device, the old model stored voip as an extra field on the apn document — but indexing the token string requires one value per row, which forces voip into its own row.What behavioral change does this introduce?
Removal used to be per-device (one document held both tokens). Now it depends on the trigger:
DELETE /v1/push.token) removes only that token's document — killing the apn token no longer removes the voip token (it matches ontokenValue, which is unique per document).authToken(same login session) and logout matches on that.So logout behavior is unchanged; the only new behavior is that a dead apn token no longer drops the voip token — more correct and self-healing, with the only edge being a short-lived orphan voip document if only the apn token is invalidated.
Is this a breaking change?
Yes — the
POST /v1/push.tokenresponse shape changes (tokenobject → flattokenValue/tokenType); this targets the next major and needs achangeset. Input/wire formats and the deprecatedraix:push-updatemethod are unchanged.What do mobile clients (mainly iOS) need to change?
POST /v1/push.tokenwith{ type, value, appName, voipToken? }. No change to how the APNs token or the PushKitvoipTokenare submitted. No forced re-registration — existing tokens are migrated server-side, and the app's next normal registration works as-is.result.tokenValue+result.tokenType, instead of the old nestedresult.token.apn/result.token.gcm. It no longer returnsresult.voipToken— when an apn token is registered together with avoipToken, the response describes only the apn document (the voip token is stored as its own document and is not echoed back). A client that readresult.token.*orresult.voipTokenfrom the response must update; a client that ignores the response body needs no change.idis now optional for voip registration (relaxed rule — no action needed). Registering avoipTokenused to require the deviceid; that requirement existed only so the server knew which document to attach the voip token to. Now that voip is its own document (keyed by its own value), there's nothing to attach it to, so theidis no longer needed — avoipTokenworks with or without it. Existing apps keep working unchanged.Summary by CodeRabbit
New Features
tokenTypeandtokenValuefields.Bug Fixes