Skip to content

Keep the chat preferences when mapping a channel push preference response - #6639

Open
gpunto wants to merge 1 commit into
developfrom
fix/channel-chat-preferences-dropped
Open

Keep the chat preferences when mapping a channel push preference response#6639
gpunto wants to merge 1 commit into
developfrom
fix/channel-chat-preferences-dropped

Conversation

@gpunto

@gpunto gpunto commented Aug 14, 2026

Copy link
Copy Markdown
Contributor

Goal

Channel chat preferences were dropped when reading a push preference response, so
PushPreference.chatPreferences was always null for a channel.

Part of AND-1291

Implementation

  • Re-vendor ChannelPushPreferencesResponse, which was vendored before the spec published
    chat_preferences, so the field was absent from the model.
  • Map it instead of passing null.

Regressed in #6628, which is not in a release yet, so no shipped version is affected. The
hand-written DownstreamPushPreferenceDto carried chat_preferences and served both the user and
the channel level. It was replaced by two generated models, and only the user-level one kept the
field. The old DTO is still used for ChannelResponse.push_preferences, which is why a channel read
back through queryChannel had the preferences while the write response did not.

Affects setChannelChatPreferences, setChannelPushPreference and snoozeChannelPushNotifications.
setChannelChatPreferences was the worst case: a caller could not read back the toggles it had just set.

A sweep for the same pattern (a mapper filling a domain field with a literal because the model has no
source for it) turned up one older instance, filed as AND-1391. It predates this migration and is not fixed here.

Testing

  • DomainMappingTest covers the mapping and the null case. The first test fails without the fix.
  • Device-probed on the wire: set all seven toggles on a channel with a distinct value each, then read the
    channel back through queryChannel, which maps the same server state through the older hand-written DTO.
    Both paths now return identical toggles; before the fix they disagreed. Also confirmed that setting a
    level clears the preferences, which is the documented behaviour, and that snoozing sets disabled_until.

Summary by CodeRabbit

  • Bug Fixes
    • Channel push preference settings now correctly preserve chat-level preferences.
    • Nested chat preference toggles are accurately reflected when provided.
    • Missing chat preferences continue to be handled safely as unavailable.

@gpunto gpunto added the pr:internal Internal changes / housekeeping label Aug 14, 2026
@github-actions

github-actions Bot commented Aug 14, 2026

Copy link
Copy Markdown
Contributor

PR checklist ✅

All required conditions are satisfied:

  • Title length is OK (or ignored by label).
  • At least one pr: label exists.
  • Sections ### Goal, ### Implementation, and ### Testing are filled, or the PR is bot-authored.
  • An issue is linked (Linear ticket or GitHub issue), or the PR is bot-authored.

🎉 Great job! This PR is ready for review.

@github-actions

Copy link
Copy Markdown
Contributor

SDK Size Comparison 📏

SDK Before After Difference Status
stream-chat-android-client 5.98 MB 5.98 MB 0.00 MB 🟢
stream-chat-android-ui-components 11.28 MB 11.28 MB 0.00 MB 🟢
stream-chat-android-compose 12.77 MB 12.77 MB 0.00 MB 🟢

@sonarqubecloud

Copy link
Copy Markdown

@gpunto
gpunto marked this pull request as ready for review August 14, 2026 11:59
@gpunto
gpunto requested a review from a team as a code owner August 14, 2026 11:59
@gpunto
gpunto enabled auto-merge August 14, 2026 11:59
@coderabbitai

coderabbitai Bot commented Aug 14, 2026

Copy link
Copy Markdown

Review Change Stack

No actionable comments were generated in the recent review. 🎉

ℹ️ Recent review info
⚙️ Run configuration

Configuration used: Repository UI

Review profile: CHILL

Plan: Pro Plus

Run ID: a304e388-7112-4d53-ac05-3c77dd9ea014

📥 Commits

Reviewing files that changed from the base of the PR and between 8a1417e and ddc6d52.

📒 Files selected for processing (3)
  • stream-chat-android-client/src/main/java/io/getstream/chat/android/client/api2/mapping/DomainMapping.kt
  • stream-chat-android-client/src/main/java/io/getstream/chat/android/network/models/ChannelPushPreferencesResponse.kt
  • stream-chat-android-client/src/test/java/io/getstream/chat/android/client/api2/mapping/DomainMappingTest.kt

Walkthrough

Channel push preference responses now include optional chat preferences. Domain mapping preserves these preferences, and tests verify nested toggles, channel levels, and null handling.

Changes

Channel push preferences

Layer / File(s) Summary
Response contract and domain mapping
stream-chat-android-client/src/main/java/io/getstream/chat/android/network/models/ChannelPushPreferencesResponse.kt, stream-chat-android-client/src/main/java/io/getstream/chat/android/client/api2/mapping/DomainMapping.kt
The response model adds nullable chatPreferences data mapped from chat_preferences. The mapper converts it to the domain model.
Mapping test coverage
stream-chat-android-client/src/test/java/io/getstream/chat/android/client/api2/mapping/DomainMappingTest.kt
Tests verify nested preference toggles, the channel preference level, and null output when chat preferences are absent.

Estimated code review effort: 2 (Simple) | ~10 minutes

Merge Risk: ⚪ Minimal · up to ddc6d

The change preserves channel chat preferences in push-preference responses and adds focused mapping coverage; no actionable merge-blocking risk remains beyond normal checks.

Suggested reviewers: velikovpetar

Poem

A bunny checked the channel with care,
Found chat preferences waiting there.
Toggles hopped in, nulls stayed clear,
The mapper now preserves them here.
“All mapped!” twitched one happy ear.

🚥 Pre-merge checks | ✅ 5
✅ Passed checks (5 passed)
Check name Status Explanation
Title check ✅ Passed The title clearly summarizes the main change: preserving chat preferences during channel push preference response mapping.
Description check ✅ Passed The description provides clear goal, implementation details, regression context, affected APIs, and comprehensive testing information.
Docstring Coverage ✅ Passed No functions found in the changed files to evaluate docstring coverage. Skipping docstring coverage check.
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
📝 Generate docstrings
  • Create stacked PR
  • Commit on current branch
🧪 Generate unit tests (beta)
  • Create PR with unit tests
  • Commit unit tests in branch fix/channel-chat-preferences-dropped

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.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

pr:internal Internal changes / housekeeping

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant