Skip to content

Migrate push preferences to generated models - #6628

Open
gpunto wants to merge 1 commit into
developfrom
migrate/push-preferences
Open

Migrate push preferences to generated models#6628
gpunto wants to merge 1 commit into
developfrom
migrate/push-preferences

Conversation

@gpunto

@gpunto gpunto commented Aug 10, 2026

Copy link
Copy Markdown
Contributor

Goal

Migrate the /push_preferences response to generated models. Part of the incremental OpenAPI model migration.

Part of AND-1291

Implementation

  • Add generated UpsertPushPreferencesResponse, PushPreferencesResponse, ChannelPushPreferencesResponse, ChatPreferencesResponse, FeedsPreferencesResponse; delete the hand-written PushPreferencesResponse wrapper (its getUserPreference/getUserChannelPreference extensions become direct map access in MoshiChatApi).
  • Add toDomain mappers for the generated preference structs. The existing DownstreamPushPreferenceDto stays (still used by user DTOs); the new mappers have distinct receiver types, so they coexist.
  • Delete PushPreferencesResponseTest (it only exercised the removed wrapper and its extensions).
  • Exclude the generated network/** path from the MaxLineLength detekt rule, so vendored models stay identical to the generator output.

Testing

  • Verified on device: setUserPushPreference(all) serializes the request and parses a real UpsertPushPreferencesResponse into the domain PushPreference.

Summary by CodeRabbit

  • Bug Fixes

    • Improved push-notification preference handling and response parsing.
    • Added support for user-level, channel-level, chat, and feed preference data.
    • Preserved existing behavior when preferences are missing or unavailable.
  • Tests

    • Updated push-preference coverage to reflect the latest response format.

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

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.96 MB 5.97 MB 0.00 MB 🟢
stream-chat-android-ui-components 11.26 MB 11.26 MB 0.00 MB 🟢
stream-chat-android-compose 12.74 MB 12.75 MB 0.01 MB 🟢

@sonarqubecloud

Copy link
Copy Markdown

Quality Gate Failed Quality Gate failed

Failed conditions
65.3% Coverage on New Code (required ≥ 80%)

See analysis details on SonarQube Cloud

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

coderabbitai Bot commented Aug 10, 2026

Copy link
Copy Markdown

Review Change Stack

Walkthrough

The pull request replaces handwritten push-preference response DTO usage with Moshi network models. It updates API parsing, domain mappings, test fixtures, and Detekt exclusions for generated network model files.

Changes

Push preferences network model migration

Layer / File(s) Summary
Define push-preference network models
stream-chat-android-client/src/main/java/io/getstream/chat/android/network/models/*PreferencesResponse.kt
Added Moshi-serializable models for push, channel, chat, and feed preferences, plus the upsert response envelope.
Wire API responses to domain preferences
stream-chat-android-client/src/main/java/io/getstream/chat/android/client/api2/endpoint/PushPreferencesApi.kt, stream-chat-android-client/src/main/java/io/getstream/chat/android/client/api2/MoshiChatApi.kt, stream-chat-android-client/src/main/java/io/getstream/chat/android/client/api2/mapping/DomainMapping.kt
Updated the endpoint and parsing logic to use preference maps. Added mappings from network responses to domain preferences.
Validate migrated response fixtures
stream-chat-android-client/src/test/java/io/getstream/chat/android/client/api2/MoshiChatApiTest.kt, config/detekt/detekt.yml
Updated push-preference fixtures for the new response structure. Excluded generated network models from the maximum line-length rule.

Estimated code review effort: 3 (Moderate) | ~20 minutes

Sequence Diagram(s)

sequenceDiagram
  participant MoshiChatApi
  participant PushPreferencesApi
  participant UpsertPushPreferencesResponse
  participant DomainMapping
  MoshiChatApi->>PushPreferencesApi: upsertPushPreferences
  PushPreferencesApi-->>MoshiChatApi: UpsertPushPreferencesResponse
  MoshiChatApi->>UpsertPushPreferencesResponse: read preference maps
  MoshiChatApi->>DomainMapping: map nested preference responses
  DomainMapping-->>MoshiChatApi: domain preferences
Loading

Possibly related PRs

Suggested reviewers: velikovpetar, andremion

Poem

I’m a rabbit with models to share,
Nesting preferences with careful care.
Maps hop through the API door,
Domain fields land safely ashore.
Generated files stretch and grow—
Detekt now lets their long lines flow.

🚥 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
Title check ✅ Passed The title clearly and concisely describes the migration of push preferences to generated models.
Description check ✅ Passed The description covers the goal, implementation, and testing, and the omitted UI sections are not relevant to this non-UI change.
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
📝 Generate docstrings 💡
  • Create stacked PR
  • Commit on current branch
🧪 Generate unit tests (beta)
  • Create PR with unit tests
  • Commit unit tests in branch migrate/push-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.

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

🧹 Nitpick comments (1)
stream-chat-android-client/src/test/java/io/getstream/chat/android/client/api2/MoshiChatApiTest.kt (1)

2937-2940: 🗄️ Data Integrity & Integration | 🔵 Trivial | ⚡ Quick win

Assert the mapped preference values.

These fixtures construct UpsertPushPreferencesResponse directly and only assert Result.Success. They do not verify PushPreference.level, disabledUntil, or chatPreferences. A regression in the new mappers or nested map selection can pass.

Assert the returned PushPreference for each user, channel, snooze, and chat-preference case. Add one JSON fixture if these tests should also cover the generated Moshi field mappings.

As per coding guidelines, add or refresh tests for changed behavior.

Also applies to: 2971-2974, 3006-3011, 3043-3048, 3082-3092, 3127-3137

🤖 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
`@stream-chat-android-client/src/test/java/io/getstream/chat/android/client/api2/MoshiChatApiTest.kt`
around lines 2937 - 2940, Update the push-preference tests around the
UpsertPushPreferencesResponse fixtures to assert the mapped PushPreference
values, not only Result.Success: verify level, disabledUntil, and
chatPreferences for each user, channel, snooze, and chat-preference scenario.
Add or refresh a JSON fixture where needed to exercise Moshi field mappings,
while preserving the existing coverage for successful responses.

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
`@stream-chat-android-client/src/test/java/io/getstream/chat/android/client/api2/MoshiChatApiTest.kt`:
- Around line 2937-2940: Update the push-preference tests around the
UpsertPushPreferencesResponse fixtures to assert the mapped PushPreference
values, not only Result.Success: verify level, disabledUntil, and
chatPreferences for each user, channel, snooze, and chat-preference scenario.
Add or refresh a JSON fixture where needed to exercise Moshi field mappings,
while preserving the existing coverage for successful responses.

ℹ️ Review info
⚙️ Run configuration

Configuration used: Repository UI

Review profile: CHILL

Plan: Pro Plus

Run ID: 8a0707b4-6689-4f85-af04-9a3213f2c055

📥 Commits

Reviewing files that changed from the base of the PR and between 3e0160e and af86681.

📒 Files selected for processing (12)
  • config/detekt/detekt.yml
  • stream-chat-android-client/src/main/java/io/getstream/chat/android/client/api2/MoshiChatApi.kt
  • stream-chat-android-client/src/main/java/io/getstream/chat/android/client/api2/endpoint/PushPreferencesApi.kt
  • 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/response/PushPreferencesResponse.kt
  • 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/network/models/ChatPreferencesResponse.kt
  • stream-chat-android-client/src/main/java/io/getstream/chat/android/network/models/FeedsPreferencesResponse.kt
  • stream-chat-android-client/src/main/java/io/getstream/chat/android/network/models/PushPreferencesResponse.kt
  • stream-chat-android-client/src/main/java/io/getstream/chat/android/network/models/UpsertPushPreferencesResponse.kt
  • stream-chat-android-client/src/test/java/io/getstream/chat/android/client/api2/MoshiChatApiTest.kt
  • stream-chat-android-client/src/test/java/io/getstream/chat/android/client/api2/model/response/PushPreferencesResponseTest.kt
💤 Files with no reviewable changes (2)
  • stream-chat-android-client/src/test/java/io/getstream/chat/android/client/api2/model/response/PushPreferencesResponseTest.kt
  • stream-chat-android-client/src/main/java/io/getstream/chat/android/client/api2/model/response/PushPreferencesResponse.kt

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