Skip to content

fix(push-preferences): align chat push preference types with the API#1786

Merged
oliverlaz merged 2 commits into
masterfrom
fix/push-preferences-types
Jun 29, 2026
Merged

fix(push-preferences): align chat push preference types with the API#1786
oliverlaz merged 2 commits into
masterfrom
fix/push-preferences-types

Conversation

@oliverlaz

@oliverlaz oliverlaz commented Jun 29, 2026

Copy link
Copy Markdown
Member

CLA

  • I have signed the Stream CLA (required).
  • Code changes are tested

Description of the changes, What, Why and How?

What — Re-models the chat push notification preference types so they match the client-side API.

Why — Reported in GetStream/stream-chat-react-native#3341. The shipped PushPreference was camelCase (callLevel, chatLevel, disabledUntil, removeDisable) and missing channel_cid / user_id, so channel-level and server-side preferences couldn't be set type-safely. The canonical client-side OpenAPI spec (chat-openapi-clientside.yaml) shows /push_preferences is entirely snake_case, and setPushPreferences posts the body verbatim (no camelCase→snake_case transform) — so the existing camelCase keys never reached the server.

How — Aligned to PushPreferenceInput / PushPreferencesResponse / ChannelPushPreferencesResponse, scoped to chat and calls (feeds out of scope):

  • PushPreference (input): call_level, channel_cid, chat_level, chat_preferences, disabled_until, remove_disable, user_id.
  • New ChatPreferences (granular per-mention prefs) and PushPreferencesResponse.
  • Widened ChatLevelPushPreference to all | mentions | direct_mentions | all_mentions | none | default.
  • Fixed ChannelPushPreference, UpsertPushPreferencesResponse, and push_preferences on ChannelAPIResponse / OwnUserBase.
  • client.setPushPreferences(prefs: PushPreference[]) is unchanged — it already wraps the array as { preferences }.

⚠️ Breaking (type-level): the old camelCase keys are removed, not kept as aliases — callLevel, chatLevel, disabledUntil, removeDisable on the input types and userPreferences / userChannelPreferences on the response. They were silently ignored by the server (input) or never populated (response), so nothing breaks at runtime, but code referencing the old names will need to switch to snake_case.

Verified with yarn types and yarn lint (zero warnings); full unit suite green.

Changelog

  • Fix PushPreference types to match the API: add channel_cid and user_id, switch to snake_case (chat_level, chat_preferences, disabled_until, remove_disable), add ChatPreferences / PushPreferencesResponse, and remove the non-functional camelCase keys.

The shipped PushPreference / ChannelPushPreference /
UpsertPushPreferencesResponse types were camelCase, but the
/push_preferences endpoint is entirely snake_case and the client posts
the body verbatim (no case transform) - so the existing keys never
reached the server, and channel_cid / user_id were missing.

Re-model the chat push preference types to match the client-side OpenAPI
spec (PushPreferenceInput / PushPreferencesResponse /
ChannelPushPreferencesResponse), scoped to chat:

- add channel_cid and user_id to PushPreference
- add chat_level / chat_preferences / disabled_until / remove_disable and
  a ChatPreferences type; widen ChatLevelPushPreference to
  all|mentions|direct_mentions|all_mentions|none|default
- add PushPreferencesResponse; fix UpsertPushPreferencesResponse and the
  push_preferences fields on ChannelAPIResponse / OwnUserBase
- remove the old camelCase keys (callLevel/chatLevel/disabledUntil/
  removeDisable, userPreferences/userChannelPreferences); they were
  silently ignored by the server

Reported in GetStream/stream-chat-react-native#3341
@github-actions

Copy link
Copy Markdown
Contributor

Size Change: 0 B

Total Size: 409 kB

ℹ️ View Unchanged
Filename Size
dist/cjs/index.browser.js 136 kB
dist/cjs/index.node.js 138 kB
dist/esm/index.mjs 135 kB

compressed-size-action

Call push notification preferences (call_level) are part of the
/push_preferences API and are documented for JavaScript, so keep them on
PushPreference and PushPreferencesResponse alongside the chat fields.
Only feeds preferences remain out of scope.
@oliverlaz oliverlaz merged commit 26c2e49 into master Jun 29, 2026
7 of 9 checks passed
@oliverlaz oliverlaz deleted the fix/push-preferences-types branch June 29, 2026 11:41
github-actions Bot pushed a commit that referenced this pull request Jun 29, 2026
## [9.48.0](v9.47.1...v9.48.0) (2026-06-29)

### Bug Fixes

* **push-preferences:** align chat push preference types with the API ([#1786](#1786)) ([26c2e49](26c2e49))
* **threads:** add notification.mark_unread handler ([#1785](#1785)) ([c60134d](c60134d)), closes [#1778](#1778)

### Features

* allow augmenting event types ([#1784](#1784)) ([c32f7e9](c32f7e9))
@stream-ci-bot

Copy link
Copy Markdown

🎉 This PR is included in version 9.48.0 🎉

The release is available on:

Your semantic-release bot 📦🚀

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.

3 participants