Sitelet https://github.com/GetStream/stream-chat-android/pull/6677
Skip to content

Migrate the push preference chat preferences to the generated model - #6677

Merged
gpunto merged 2 commits into
developfrom
migrate/chat-preferences
Sep 2, 2026
Merged

gpunto merged 2 commits into
developfrom
migrate/chat-preferences

Conversation

@gpunto

@gpunto gpunto commented Sep 1, 2026 •

Copy link
Copy Markdown
Contributor

Goal

Parse a push preference's chat preferences with the generated ChatPreferencesResponse and delete the hand-written DownstreamChatPreferencesDto.

Part of AND-1291

Implementation

  • Point DownstreamPushPreferenceDto.chat_preferences at ChatPreferencesResponse and drop DownstreamChatPreferencesDto. Its mapper was identical field for field to the existing ChatPreferencesResponse.toDomain(), already used by PushPreferencesResponse and ChannelPushPreferencesResponse, so the duplicate goes with it and no new mapping code is needed.
  • Rename PushPreferenceDtos.kt to DownstreamPushPreferenceDto.kt, since removing the class leaves a single declaration.
  • Add a mapping test over the whole PushPreference, with the seven toggles alternating so a preference read from the wrong field cannot pass. chat_preferences had no coverage on this path before: neither Mother.randomDownstreamPushPreferenceDto nor UserDtoTestData populated it, and the closest existing test covered a different model while asserting two of the seven toggles.

The generated ChatPreferences model is a different, 8-field type belonging to channel config, not the push preference payload. ChatPreferencesResponse matches the removed DTO exactly, so no field is gained or lost.

Testing

  • Device probe: set channel chat preferences with the toggles alternating, then re-read through the channel query, which is the path that parses this field. All seven toggles round-tripped on both the write response and the re-read, with a populated chatPreferences.
  • Mutation checks: dropping chat_preferences from the mapping, and reading one toggle from the wrong source field, each fail the new test.

Summary by CodeRabbit

  • Bug Fixes
    • Improved push preference handling by consistently applying chat preference settings.
    • Preserved push levels, disabled-until dates, and individual notification toggles when converting preferences for app use.
  • Tests
    • Added coverage to verify all chat preference options are correctly retained during push preference processing.

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

github-actions Bot commented Sep 1, 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

github-actions Bot commented Sep 1, 2026

Copy link
Copy Markdown
Contributor

SDK Size Comparison 📏

SDK Before After Difference Status
stream-chat-android-client 6.11 MB 6.11 MB 0.00 MB 🟢
stream-chat-android-ui-components 11.42 MB 11.42 MB -0.00 MB 🚀
stream-chat-android-compose 12.90 MB 12.90 MB 0.00 MB 🟢

@gpunto
gpunto marked this pull request as ready for review September 1, 2026 10:20
@gpunto
gpunto requested a review from a team as a code owner September 1, 2026 10:20
@coderabbitai

coderabbitai Bot commented Sep 1, 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: Team

Run ID: 5736182a-50a2-4a01-acd7-32444f8fdf50

📥 Commits

Reviewing files that changed from the base of the PR and between 32addbe and 56ad0c3.

📒 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/client/api2/model/dto/DownstreamPushPreferenceDto.kt
  • stream-chat-android-client/src/test/java/io/getstream/chat/android/client/api2/mapping/DomainMappingTest.kt
💤 Files with no reviewable changes (1)
  • stream-chat-android-client/src/main/java/io/getstream/chat/android/client/api2/mapping/DomainMapping.kt

Included review availability: Your plan provides up to 4 included reviews per hour; 3 remain after this review.


Walkthrough

The push preference DTO now uses the shared ChatPreferencesResponse model. The obsolete local DTO and mapping were removed. A test verifies conversion to the domain PushPreference.

Changes

Push preference alignment

Layer / File(s) Summary
Adopt shared chat preferences model
stream-chat-android-client/src/main/java/io/getstream/chat/android/client/api2/model/dto/DownstreamPushPreferenceDto.kt, stream-chat-android-client/src/main/java/io/getstream/chat/android/client/api2/mapping/DomainMapping.kt
DownstreamPushPreferenceDto now uses ChatPreferencesResponse. The obsolete DTO and its mapping function were removed.
Validate push preference mapping
stream-chat-android-client/src/test/java/io/getstream/chat/android/client/api2/mapping/DomainMappingTest.kt
The test verifies the push level, disabled-until date, and all seven chat preference toggles.

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

Merge Risk: ⚪ Minimal · up to 56ad0

This change reuses the existing response model without changing the public push-preference behavior, while adding coverage for all chat-preference toggles. No actionable merge-blocking risk remains after normal checks and review.

Suggested reviewers: aleksandar-apostolov, andremion, kanat

Poem

A rabbit mapped each toggle bright
Shared fields now hop in line
Old DTOs vanish from sight
Tests check every sign
Push preferences land just right

🚥 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%. Docstring coverage is scoped to functions touched by this diff. Analyzed 3 functions across 2 files. Write docstrings for the functions missing them to satisfy the coverage threshold.
✅ Passed checks (4 passed)
Check name Status Explanation
Title check ✅ Passed The title clearly and concisely describes the main change: migrating push preference chat preferences to the generated model.
Description check ✅ Passed The description provides the goal, implementation details, issue reference, testing evidence, and mutation-check results. It omits the UI Changes, contributor checklist, reviewer checklist, and GIF se…
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.
Full details: Description check

Explanation

The description provides the goal, implementation details, issue reference, testing evidence, and mutation-check results. It omits the UI Changes, contributor checklist, reviewer checklist, and GIF sections, but these are not critical for this non-UI change.

  • Fix all pre-merge checks with AI
✨ Finishing Touches 💡 1
📝 Generate docstrings 💡
  • Create stacked PR
  • Commit on current branch
🧪 Generate unit tests (beta)
  • Create PR with unit tests
  • Commit unit tests in branch migrate/chat-preferences

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.

@andremion andremion 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.

Looks good. One optional test note inline.

@sonarqubecloud

sonarqubecloud Bot commented Sep 1, 2026

Copy link
Copy Markdown

@gpunto
gpunto added this pull request to the merge queue Sep 2, 2026
Merged via the queue into develop with commit 829a45a Sep 2, 2026
19 checks passed
@gpunto
gpunto deleted the migrate/chat-preferences branch September 2, 2026 08:10
@stream-public-bot stream-public-bot added the released Included in a release label Sep 10, 2026
@stream-public-bot

Copy link
Copy Markdown
Contributor

🚀 Available in v7.11.0

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

Labels

pr:internal Internal changes / housekeeping released Included in a release

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants