Migrate queryReactions request body to the generated QueryReactionsRequest model#6564
Conversation
PR checklist ✅All required conditions are satisfied:
🎉 Great job! This PR is ready for review. |
SDK Size Comparison 📏
|
WalkthroughQueryReactionsRequest and SortParamRequest models are relocated/redefined under io.getstream.chat.android.network.models. MoshiChatApi now converts sort via a new toSortParams() extension instead of toDto() when building queryReactions. Imports in MessageApi and tests are updated accordingly, and new parser adapter tests with test data are added. ChangesQueryReactions Sort Model Migration
Estimated code review effort: 2 (Simple) | ~15 minutes Sequence Diagram(s)sequenceDiagram
participant MoshiChatApi
participant QuerySorter
participant QueryReactionsRequest
MoshiChatApi->>QuerySorter: toSortParams()
QuerySorter-->>MoshiChatApi: List<SortParamRequest>
MoshiChatApi->>QueryReactionsRequest: build with sort params
Suggested reviewers: Poem
🚥 Pre-merge checks | ✅ 4 | ❌ 1❌ Failed checks (1 warning)
✅ Passed checks (4 passed)
✨ Finishing Touches📝 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)
452-465: 🎯 Functional Correctness | 🔵 Trivial | ⚡ Quick winTest doesn't exercise the new
toSortParams()field/direction mapping.
sort = QuerySortByField<Reaction>()is empty, sotoSortParams()'s extraction/casting logic (the new code this PR introduces) always maps to an empty list here — the test can't catch a regression in that mapping. Other tests in this class (e.g.testQueryBannedUsers) use a populated sorter to actually exercise the mapping.♻️ Suggested fix: use a populated sorter
- val sort = QuerySortByField<Reaction>() + val sort = QuerySortByField.descByName<Reaction>("created_at")🤖 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 452 - 465, The test in MoshiChatApiTest.queryReactions uses an empty QuerySortByField, so it never exercises the new toSortParams() field/direction mapping. Update this test to build a populated QuerySortByField<Reaction> with at least one field and sort direction, then keep the expected QueryReactionsRequest assertion using sort.toSortParams() so the mapping logic is actually verified. Use the existing queryReactions and QuerySortByField helpers in this test class as the reference points.
🤖 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 452-465: The test in MoshiChatApiTest.queryReactions uses an empty
QuerySortByField, so it never exercises the new toSortParams() field/direction
mapping. Update this test to build a populated QuerySortByField<Reaction> with
at least one field and sort direction, then keep the expected
QueryReactionsRequest assertion using sort.toSortParams() so the mapping logic
is actually verified. Use the existing queryReactions and QuerySortByField
helpers in this test class as the reference points.
ℹ️ Review info
⚙️ Run configuration
Configuration used: Repository UI
Review profile: CHILL
Plan: Pro
Run ID: d63a43fd-b824-4c97-9227-9c6d6d7f4122
📒 Files selected for processing (7)
stream-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/MessageApi.ktstream-chat-android-client/src/main/java/io/getstream/chat/android/network/models/QueryReactionsRequest.ktstream-chat-android-client/src/main/java/io/getstream/chat/android/network/models/SortParamRequest.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/parser2/QueryReactionsRequestAdapterTest.ktstream-chat-android-client/src/test/java/io/getstream/chat/android/client/parser2/testdata/QueryReactionsRequestTestData.kt
|
|
🚀 Available in v7.6.0 |


Goal
Migrate the
queryReactionsrequest body (POST /messages/{id}/reactions) to the generatedQueryReactionsRequestnetwork model. Introduces the sharedSortParamRequestmodel + aQuerySorter -> List<SortParamRequest>helper that the remaining query-payload migrations will reuse. Part of the incremental OpenAPI model migration.Part of AND-1291
Implementation
internal QueryReactionsRequest+SortParamRequestinnetwork.models(patch-free). Delete the hand-writtenapi2.model.requests.QueryReactionsRequest. Real names, no alias.sortfield is nowList<SortParamRequest>(wasList<Map<String, Any>>). Add a top-levelinternal fun QuerySorter<*>.toSortParams(): List<SortParamRequest>(ported from the reference) mapping each sort entry toSortParamRequest(field, direction), and change thequeryReactionscall site fromsort = sort?.toDto()tosort = sort?.toSortParams().filter?.toMap()(Map<String, Any>) fits the generatedMap<String, Any?>field. No wire-shape change.Testing
spotlessApply,apiCheck(no API drift),detekt, and the full clienttestDebugUnitTestsuite pass.queryReactionswith acreated_at descsort serializes on the wire as{"limit":10,"sort":[{"direction":-1,"field":"created_at"}]}and returns201. Thesortarray confirms the newSortParamRequestserialization viatoSortParams()(the migration's changed surface; the response type is unchanged by this slice).Summary by CodeRabbit
New Features
Bug Fixes
Tests