Migrate push preferences to generated models - #6628
Conversation
PR checklist ✅All required conditions are satisfied:
🎉 Great job! This PR is ready for review. |
SDK Size Comparison 📏
|
|
WalkthroughThe 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. ChangesPush preferences network model migration
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
Possibly related PRs
Suggested reviewers: Poem
🚥 Pre-merge checks | ✅ 4 | ❌ 1❌ Failed checks (1 warning)
✅ Passed checks (4 passed)
✨ Finishing Touches 💡 1📝 Generate docstrings 💡
🧪 Generate unit tests (beta)
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. Comment |
There was a problem hiding this comment.
🧹 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 winAssert the mapped preference values.
These fixtures construct
UpsertPushPreferencesResponsedirectly and only assertResult.Success. They do not verifyPushPreference.level,disabledUntil, orchatPreferences. A regression in the new mappers or nested map selection can pass.Assert the returned
PushPreferencefor 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
📒 Files selected for processing (12)
config/detekt/detekt.ymlstream-chat-android-client/src/main/java/io/getstream/chat/android/client/api2/MoshiChatApi.ktstream-chat-android-client/src/main/java/io/getstream/chat/android/client/api2/endpoint/PushPreferencesApi.ktstream-chat-android-client/src/main/java/io/getstream/chat/android/client/api2/mapping/DomainMapping.ktstream-chat-android-client/src/main/java/io/getstream/chat/android/client/api2/model/response/PushPreferencesResponse.ktstream-chat-android-client/src/main/java/io/getstream/chat/android/network/models/ChannelPushPreferencesResponse.ktstream-chat-android-client/src/main/java/io/getstream/chat/android/network/models/ChatPreferencesResponse.ktstream-chat-android-client/src/main/java/io/getstream/chat/android/network/models/FeedsPreferencesResponse.ktstream-chat-android-client/src/main/java/io/getstream/chat/android/network/models/PushPreferencesResponse.ktstream-chat-android-client/src/main/java/io/getstream/chat/android/network/models/UpsertPushPreferencesResponse.ktstream-chat-android-client/src/test/java/io/getstream/chat/android/client/api2/MoshiChatApiTest.ktstream-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


Goal
Migrate the
/push_preferencesresponse to generated models. Part of the incremental OpenAPI model migration.Part of AND-1291
Implementation
UpsertPushPreferencesResponse,PushPreferencesResponse,ChannelPushPreferencesResponse,ChatPreferencesResponse,FeedsPreferencesResponse; delete the hand-writtenPushPreferencesResponsewrapper (itsgetUserPreference/getUserChannelPreferenceextensions become direct map access inMoshiChatApi).toDomainmappers for the generated preference structs. The existingDownstreamPushPreferenceDtostays (still used by user DTOs); the new mappers have distinct receiver types, so they coexist.PushPreferencesResponseTest(it only exercised the removed wrapper and its extensions).network/**path from theMaxLineLengthdetekt rule, so vendored models stay identical to the generator output.Testing
setUserPushPreference(all)serializes the request and parses a realUpsertPushPreferencesResponseinto the domainPushPreference.Summary by CodeRabbit
Bug Fixes
Tests