Skip to content

refactor: index token string via tokenValue/tokenType pair - #41382

Open
ricardogarim wants to merge 3 commits into
release-9.0.0from
refactor/push-token-index
Open

refactor: index token string via tokenValue/tokenType pair#41382
ricardogarim wants to merge 3 commits into
release-9.0.0from
refactor/push-token-index

Conversation

@ricardogarim

@ricardogarim ricardogarim commented Jul 15, 2026

Copy link
Copy Markdown
Member

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, indexable tokenValue / tokenType pair.

Ships a data migration (v336) that rewrites/splits every _raix_push_app_tokens document.

Breaking change — the POST /v1/push.token response shape changes (token object → flat tokenValue/tokenType). Targets the next major; Request/input formats are unchanged.

  • Storage: the token: { apn | gcm } object → tokenValue: string + tokenType: 'apn' | 'gcm' | 'voip'. The voipToken field is removed — a VoIP token is now a first-class tokenType: 'voip' in its own document (so a VoIP-capable iOS device becomes two documents).
  • Indexes: added { tokenValue }, { appName, tokenValue }, { tokenType }; dropped the now-meaningless { appName, token }. Every token-string lookup is now index-backed.
  • Migration v336: flattens each legacy document; a coexisting voipToken is split into its own voip document with a deterministic _id (idempotent).
  • Send path: routes by tokenType (voip → APN with the .voip topic; apn/gcm → regular). Registration writes two documents when a voipToken is supplied.
  • REST: POST /v1/push.token now returns a flat { tokenValue, tokenType } instead of the nested { token: { apn|gcm } }. Request/input formats are unchanged.

Issue(s)

Steps to test or reproduce

  1. On a pre-migration DB, register apn, gcm, and an apn token carrying a voipToken via POST /v1/push.token.
  2. Start the server so v336 runs → legacy docs become tokenValue/tokenType, and each apn+voip doc splits into two (<id> and <id>_voip).
  3. POST /v1/push.token again → the response is flat tokenValue/tokenType.
  4. Send a regular push and a VoIP push (useVoipToken) to a user with both documents → each reaches only the correct token/topic.
  5. DELETE /v1/push.token with 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 .voip topic). VoIP tokens are iOS-only — Android/FCM has no separate VoIP token (it uses high-priority FCM messages on the same token), so gcm never 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:

  • A token reported invalid (or DELETE /v1/push.token) removes only that token's document — killing the apn token no longer removes the voip token (it matches on tokenValue, which is unique per document).
  • Logout still removes both, because the apn and voip documents share the same 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.token response shape changes (token object → flat tokenValue/tokenType); this targets the next major and needs a changeset. Input/wire formats and the deprecated raix:push-update method are unchanged.

What do mobile clients (mainly iOS) need to change?
  • Registration requests are UNCHANGED. Keep sending POST /v1/push.token with { type, value, appName, voipToken? }. No change to how the APNs token or the PushKit voipToken are submitted. No forced re-registration — existing tokens are migrated server-side, and the app's next normal registration works as-is.
  • Only if the client reads the register response: it now returns the primary (apn/gcm) document as flat result.tokenValue + result.tokenType, instead of the old nested result.token.apn / result.token.gcm. It no longer returns result.voipToken — when an apn token is registered together with a voipToken, the response describes only the apn document (the voip token is stored as its own document and is not echoed back). A client that read result.token.* or result.voipToken from the response must update; a client that ignores the response body needs no change.
  • The id is now optional for voip registration (relaxed rule — no action needed). Registering a voipToken used to require the device id; 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 the id is no longer needed — a voipToken works with or without it. Existing apps keep working unchanged.

Summary by CodeRabbit

  • New Features

    • Push token data is now returned as flat tokenType and tokenValue fields.
    • VoIP tokens are stored and managed separately from device push tokens.
    • Push delivery now routes APN, GCM, and VoIP notifications using the normalized token format.
  • Bug Fixes

    • Improved token matching, duplicate cleanup, and delivery handling across supported push providers.
    • Existing push tokens are automatically migrated to the new format.

@dionisio-bot

dionisio-bot Bot commented Jul 15, 2026

Copy link
Copy Markdown
Contributor

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

  • This PR is missing the 'stat: QA assured' label

Please fix the issues and try again

If you have any trouble, please check the PR guidelines

@changeset-bot

changeset-bot Bot commented Jul 15, 2026

Copy link
Copy Markdown

🦋 Changeset detected

Latest commit: fc59d28

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

This PR includes changesets to release 6 packages
Name Type
@rocket.chat/meteor Major
@rocket.chat/core-services Patch
@rocket.chat/model-typings Patch
@rocket.chat/core-typings Major
@rocket.chat/models Patch
@rocket.chat/rest-typings 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

coderabbitai Bot commented Jul 15, 2026

Copy link
Copy Markdown
Contributor

Review Change Stack

Walkthrough

Push-token records now use flat tokenType and tokenValue fields. VoIP tokens use separate documents. Registration, migration, API responses, persistence, notification delivery, and tests support the normalized structure.

Changes

Push-token normalization

Layer / File(s) Summary
Token contracts and model interfaces
packages/core-typings/src/IPushToken.ts, packages/model-typings/src/models/IPushTokenModel.ts, packages/core-services/src/types/IPushService.ts, apps/meteor/server/meteor-methods/platform/push.ts
Push-token types and model contracts now use tokenType and tokenValue. Registration accepts APN/GCM targets and an optional VoIP token.
Storage migration and model operations
packages/models/src/models/PushToken.ts, apps/meteor/server/startup/migrations/*
Indexes, queries, writes, deduplication, and deletion use normalized fields. Migration 337 converts legacy records and recreates indexes.
Registration pipeline and API response
apps/meteor/server/services/push/..., apps/meteor/server/api/v1/push.ts, apps/meteor/tests/end-to-end/api/push.ts, .changeset/fancy-zebras-go.md
Registration stores platform and VoIP tokens as separate documents. The API returns flat tokenType and tokenValue fields. End-to-end tests verify the response.
Native and gateway notification routing
apps/meteor/server/lib/notifications/push/push.ts, apps/meteor/tests/unit/server/lib/notifications/push/push.spec.ts
Native and gateway delivery route by normalized token fields, enforce VoIP mode matching, and delete invalid tokens by token value. Routing tests cover APN, VoIP, and GCM paths.

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
Loading
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
Loading

Possibly related PRs

Suggested labels: type: chore

Suggested reviewers: kevlehman, tassoevan

🚥 Pre-merge checks | ✅ 4 | ❌ 1

❌ Failed checks (1 warning)

Check name Status Explanation Resolution
Docstring Coverage ⚠️ Warning Docstring coverage is 0.00% which is insufficient. The required threshold is 80.00%. Write docstrings for the functions missing them to satisfy the coverage threshold.
✅ Passed checks (4 passed)
Check name Status Explanation
Description Check ✅ Passed Check skipped - CodeRabbit’s high-level summary is enabled.
Title check ✅ Passed The title clearly summarizes the main refactor to index push tokens using the tokenValue and tokenType pair.
Linked Issues check ✅ Passed Check skipped because no linked issues were found for this pull request.
Out of Scope Changes check ✅ Passed Check skipped because no linked issues were found for this pull request.
✨ Finishing Touches 💡 1
🛠️ Fix failing CI checks 💡
  • Create stacked PR
  • Commit on current branch

Warning

Review ran into problems

🔥 Problems

Errors were encountered while retrieving linked issues.

Errors (1)
  • CORE-2101: Request failed with status code 401

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.

@ricardogarim ricardogarim added this to the 9.0.0 milestone Jul 15, 2026

@coderabbitai coderabbitai Bot left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

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 win

Require the normalized fields in the response schema.

PushTokenResult requires these fields, but AJV currently accepts an empty result object. Add a nested required array 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 win

Remove the implementation comment.

The surrounding tokenType argument 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 win

Import IPushToken from the package root.

@rocket.chat/core-typings re-exports IPushToken, so this test should avoid the internal src/IPushToken path.

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 value

Remove 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

📥 Commits

Reviewing files that changed from the base of the PR and between 0faaaeb and f297920.

📒 Files selected for processing (15)
  • .changeset/fancy-zebras-go.md
  • apps/meteor/server/api/v1/push.ts
  • apps/meteor/server/lib/notifications/push/push.ts
  • apps/meteor/server/meteor-methods/platform/push.ts
  • apps/meteor/server/services/push/lib/findDocumentToUpdate.ts
  • apps/meteor/server/services/push/lib/registerPushToken.ts
  • apps/meteor/server/services/push/service.ts
  • apps/meteor/server/startup/migrations/index.ts
  • apps/meteor/server/startup/migrations/v336.ts
  • apps/meteor/tests/end-to-end/api/push.ts
  • apps/meteor/tests/unit/server/lib/notifications/push/push.spec.ts
  • packages/core-services/src/types/IPushService.ts
  • packages/core-typings/src/IPushToken.ts
  • packages/model-typings/src/models/IPushTokenModel.ts
  • packages/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.ts
  • apps/meteor/server/startup/migrations/v336.ts
  • packages/core-services/src/types/IPushService.ts
  • apps/meteor/tests/end-to-end/api/push.ts
  • apps/meteor/server/meteor-methods/platform/push.ts
  • apps/meteor/server/services/push/lib/findDocumentToUpdate.ts
  • apps/meteor/server/services/push/lib/registerPushToken.ts
  • apps/meteor/tests/unit/server/lib/notifications/push/push.spec.ts
  • packages/model-typings/src/models/IPushTokenModel.ts
  • apps/meteor/server/services/push/service.ts
  • packages/core-typings/src/IPushToken.ts
  • apps/meteor/server/lib/notifications/push/push.ts
  • apps/meteor/server/api/v1/push.ts
  • packages/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.ts extension 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.ts
  • apps/meteor/server/startup/migrations/v336.ts
  • packages/core-services/src/types/IPushService.ts
  • apps/meteor/tests/end-to-end/api/push.ts
  • apps/meteor/server/meteor-methods/platform/push.ts
  • apps/meteor/server/services/push/lib/findDocumentToUpdate.ts
  • apps/meteor/server/services/push/lib/registerPushToken.ts
  • apps/meteor/tests/unit/server/lib/notifications/push/push.spec.ts
  • packages/model-typings/src/models/IPushTokenModel.ts
  • apps/meteor/server/services/push/service.ts
  • packages/core-typings/src/IPushToken.ts
  • apps/meteor/server/lib/notifications/push/push.ts
  • apps/meteor/server/api/v1/push.ts
  • packages/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.ts
  • apps/meteor/server/startup/migrations/v336.ts
  • packages/core-services/src/types/IPushService.ts
  • apps/meteor/tests/end-to-end/api/push.ts
  • apps/meteor/server/meteor-methods/platform/push.ts
  • apps/meteor/server/services/push/lib/findDocumentToUpdate.ts
  • apps/meteor/server/services/push/lib/registerPushToken.ts
  • apps/meteor/tests/unit/server/lib/notifications/push/push.spec.ts
  • packages/model-typings/src/models/IPushTokenModel.ts
  • apps/meteor/server/services/push/service.ts
  • packages/core-typings/src/IPushToken.ts
  • apps/meteor/server/lib/notifications/push/push.ts
  • apps/meteor/server/api/v1/push.ts
  • packages/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.ts
  • apps/meteor/server/startup/migrations/v336.ts
  • packages/core-services/src/types/IPushService.ts
  • apps/meteor/tests/end-to-end/api/push.ts
  • apps/meteor/server/meteor-methods/platform/push.ts
  • apps/meteor/server/services/push/lib/findDocumentToUpdate.ts
  • apps/meteor/server/services/push/lib/registerPushToken.ts
  • apps/meteor/tests/unit/server/lib/notifications/push/push.spec.ts
  • packages/model-typings/src/models/IPushTokenModel.ts
  • apps/meteor/server/services/push/service.ts
  • packages/core-typings/src/IPushToken.ts
  • apps/meteor/server/lib/notifications/push/push.ts
  • apps/meteor/server/api/v1/push.ts
  • packages/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 in IPushTokenModel.

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

Comment thread apps/meteor/server/startup/migrations/v336.ts Outdated
Comment thread packages/core-typings/src/IPushToken.ts
Comment thread packages/model-typings/src/models/IPushTokenModel.ts
@codecov

codecov Bot commented Jul 15, 2026

Copy link
Copy Markdown

Codecov Report

❌ Patch coverage is 20.40816% with 39 lines in your changes missing coverage. Please review.
✅ Project coverage is 68.83%. Comparing base (416bb8a) to head (fc59d28).

Additional details and impacted files

Impacted file tree graph

@@                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     
Flag Coverage Δ
e2e 59.20% <ø> (-0.02%) ⬇️
e2e-api 46.03% <20.40%> (-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.

@ricardogarim
ricardogarim force-pushed the refactor/push-token-index branch from 0e9fccb to 44b5d45 Compare July 15, 2026 01:29
@ricardogarim
ricardogarim marked this pull request as ready for review July 15, 2026 12:07
@ricardogarim
ricardogarim requested review from a team as code owners July 15, 2026 12:07
@coderabbitai coderabbitai Bot added type: feature Pull requests that introduces new feature and removed type: chore labels Jul 15, 2026

@cubic-dev-ai cubic-dev-ai Bot left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

All reported issues were addressed across 15 files

Reply with feedback, questions, or to request a fix.

Re-trigger cubic

Comment thread packages/models/src/models/PushToken.ts
Comment thread apps/meteor/server/startup/migrations/v336.ts Outdated
Comment thread packages/models/src/models/PushToken.ts

@hacktron-app hacktron-app Bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

1 issue found across 1 file

Severity Count
MEDIUM 1

View full scan results

@ricardogarim
ricardogarim marked this pull request as draft July 15, 2026 19:07
@ricardogarim
ricardogarim force-pushed the refactor/push-token-index branch from 44b5d45 to bd0b525 Compare July 16, 2026 01:22
@ricardogarim
ricardogarim changed the base branch from develop to release-9.0.0 July 16, 2026 01:22
@ricardogarim
ricardogarim marked this pull request as ready for review July 16, 2026 12:06

@cubic-dev-ai cubic-dev-ai Bot left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

No issues found across 15 files

Re-trigger cubic

@ricardogarim
ricardogarim force-pushed the refactor/push-token-index branch from bd0b525 to 98465e6 Compare August 6, 2026 12:41

@dionisio-bot dionisio-bot Bot left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Changeset mismatch

A changeset declares a major bump, but the PR title does not indicate a breaking change (use type!: ... or type(scope)!: ...).

Please align the PR title, milestone and changesets.

@dionisio-bot dionisio-bot Bot left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Changeset mismatch

A changeset declares a major bump, but the PR title does not indicate a breaking change (use type!: ... or type(scope)!: ...).

Please align the PR title, milestone and changesets.

@dionisio-bot dionisio-bot Bot left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Changeset mismatch

A changeset declares a major bump, but the PR title does not indicate a breaking change (use type!: ... or type(scope)!: ...).

Please align the PR title, milestone and changesets.

@coderabbitai

coderabbitai Bot commented Aug 6, 2026

Copy link
Copy Markdown
Contributor

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.

@dionisio-bot dionisio-bot Bot left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Changeset mismatch

A changeset declares a major bump, but the PR title does not indicate a breaking change (use type!: ... or type(scope)!: ...).

Please align the PR title, milestone and changesets.

@dionisio-bot dionisio-bot Bot left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Changeset mismatch

A changeset declares a major bump, but the PR title does not indicate a breaking change (use type!: ... or type(scope)!: ...).

Please align the PR title, milestone and changesets.

@ricardogarim
ricardogarim requested review from a team and removed request for a team August 6, 2026 12:42
@coderabbitai coderabbitai Bot added type: chore and removed type: feature Pull requests that introduces new feature labels Aug 6, 2026

@coderabbitai coderabbitai Bot left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

🧹 Nitpick comments (1)
apps/meteor/server/startup/migrations/v337.ts (1)

11-11: 📐 Maintainability & Code Quality | 🔵 Trivial | 💤 Low value

Remove 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

📥 Commits

Reviewing files that changed from the base of the PR and between 416bb8a and 98465e6.

📒 Files selected for processing (15)
  • .changeset/fancy-zebras-go.md
  • apps/meteor/server/api/v1/push.ts
  • apps/meteor/server/lib/notifications/push/push.ts
  • apps/meteor/server/meteor-methods/platform/push.ts
  • apps/meteor/server/services/push/service.ts
  • apps/meteor/server/services/push/tokenManagement/findDocumentToUpdate.ts
  • apps/meteor/server/services/push/tokenManagement/registerPushToken.ts
  • apps/meteor/server/startup/migrations/index.ts
  • apps/meteor/server/startup/migrations/v337.ts
  • apps/meteor/tests/end-to-end/api/push.ts
  • apps/meteor/tests/unit/server/lib/notifications/push/push.spec.ts
  • packages/core-services/src/types/IPushService.ts
  • packages/core-typings/src/IPushToken.ts
  • packages/model-typings/src/models/IPushTokenModel.ts
  • packages/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

View job details

**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

View job details

**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

View job details

**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.ts
  • apps/meteor/server/services/push/tokenManagement/findDocumentToUpdate.ts
  • apps/meteor/server/services/push/tokenManagement/registerPushToken.ts
  • packages/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.ts
  • apps/meteor/server/services/push/tokenManagement/findDocumentToUpdate.ts
  • apps/meteor/server/services/push/tokenManagement/registerPushToken.ts
  • packages/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.ts
  • apps/meteor/server/services/push/tokenManagement/findDocumentToUpdate.ts
  • apps/meteor/server/services/push/tokenManagement/registerPushToken.ts
  • packages/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.ts
  • apps/meteor/server/services/push/tokenManagement/findDocumentToUpdate.ts
  • apps/meteor/server/services/push/tokenManagement/registerPushToken.ts
  • packages/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.ts
  • apps/meteor/server/services/push/tokenManagement/findDocumentToUpdate.ts
  • apps/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

@ricardogarim
ricardogarim force-pushed the refactor/push-token-index branch from 98465e6 to fc59d28 Compare August 8, 2026 15:56
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant