Migrate sendEvent request body to the generated SendEventRequest model - #6617
Migrate sendEvent request body to the generated SendEventRequest model#6617gpunto wants to merge 1 commit into
Conversation
PR checklist ✅All required conditions are satisfied:
🎉 Great job! This PR is ready for review. |
SDK Size Comparison 📏
|
0c1aa06 to
2856304
Compare
WalkthroughThis change replaces map-based event payloads with typed network models. It adds Moshi serialization for ChangesEvent request typing and serialization
Estimated code review effort: 3 (Moderate) | ~20 minutes Suggested reviewers: Poem
🚥 Pre-merge checks | ✅ 5✅ Passed checks (5 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.
Actionable comments posted: 1
🧹 Nitpick comments (2)
stream-chat-android-client/src/test/java/io/getstream/chat/android/client/api2/MoshiChatApiTest.kt (1)
2352-2362: 📐 Maintainability & Code Quality | 🔵 Trivial | ⚡ Quick winCover non-empty
extraDatamapping.This test only verifies
emptyMap(). Add a case with a non-String key and assert thatChannelApi.sendEventreceives the corresponding string key inEventRequest.custom. This protects the conversion added inMoshiChatApi.sendEvent.As per coding guidelines, “add or refresh tests for changed behavior.”
Proposed test update
- val extraData = emptyMap<Any, Any>() + val extraData = mapOf<Any, Any>(123 to "value") ... val expectedRequest = SendEventRequest( - event = EventRequest(type = eventType, custom = emptyMap()), + event = EventRequest(type = eventType, custom = mapOf("123" to "value")), )🤖 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 2352 - 2362, Update the sendEvent test around MoshiChatApi.sendEvent to use non-empty extraData containing a non-String key, then assert the verified ChannelApi.sendEvent request contains the corresponding stringified key in EventRequest.custom. Preserve the existing result assertion and Mockito verification while covering the new mapping behavior.Source: Coding guidelines
stream-chat-android-client/src/main/java/io/getstream/chat/android/network/models/EventRequest.kt (1)
17-22: 📐 Maintainability & Code Quality | 🔵 Trivial | 💤 Low valueDocument or remove these suppressions.
The suppressions have no documented reason. Remove entries that are not required. Document any suppression that the Moshi generation or adapter signature requires.
stream-chat-android-client/src/main/java/io/getstream/chat/android/network/models/EventRequest.kt#L17-L22: remove unused file-level suppression entries or document why the generated model requires them.stream-chat-android-client/src/main/java/io/getstream/chat/android/network/models/SendEventRequest.kt#L17-L22: remove unused file-level suppression entries or document why the generated model requires them.stream-chat-android-client/src/main/java/io/getstream/chat/android/client/parser2/adapters/EventRequestAdapter.kt#L32-L34: replace the unused parameter name with_if Moshi does not require the name, or document the suppression.As per coding guidelines, “avoid suppressions unless documented.”
🤖 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/main/java/io/getstream/chat/android/network/models/EventRequest.kt` around lines 17 - 22, Remove any unused file-level suppressions from EventRequest.kt and SendEventRequest.kt, and keep only the entries that Moshi-generated models actually require with an inline note explaining the need; for EventRequestAdapter.kt, update the adapter method signature to use an underscore for any truly unused parameter name unless Moshi requires the named parameter, in which case document the suppression at that symbol. Apply the fix at stream-chat-android-client/src/main/java/io/getstream/chat/android/network/models/EventRequest.kt#L17-L22, stream-chat-android-client/src/main/java/io/getstream/chat/android/network/models/SendEventRequest.kt#L17-L22, and stream-chat-android-client/src/main/java/io/getstream/chat/android/client/parser2/adapters/EventRequestAdapter.kt#L32-L34, preserving only documented suppressions.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.
Inline comments:
In
`@stream-chat-android-client/src/main/java/io/getstream/chat/android/client/api2/MoshiChatApi.kt`:
- Around line 1674-1681: Update serializeWithExtraData around the
extraData-to-custom mapping to reject reserved custom keys, at minimum the
"type" key, before constructing and sending SendEventRequest. Ensure
custom["type"] cannot override EventRequest(type = eventType), while preserving
all other custom data handling.
---
Nitpick comments:
In
`@stream-chat-android-client/src/main/java/io/getstream/chat/android/network/models/EventRequest.kt`:
- Around line 17-22: Remove any unused file-level suppressions from
EventRequest.kt and SendEventRequest.kt, and keep only the entries that
Moshi-generated models actually require with an inline note explaining the need;
for EventRequestAdapter.kt, update the adapter method signature to use an
underscore for any truly unused parameter name unless Moshi requires the named
parameter, in which case document the suppression at that symbol. Apply the fix
at
stream-chat-android-client/src/main/java/io/getstream/chat/android/network/models/EventRequest.kt#L17-L22,
stream-chat-android-client/src/main/java/io/getstream/chat/android/network/models/SendEventRequest.kt#L17-L22,
and
stream-chat-android-client/src/main/java/io/getstream/chat/android/client/parser2/adapters/EventRequestAdapter.kt#L32-L34,
preserving only documented suppressions.
In
`@stream-chat-android-client/src/test/java/io/getstream/chat/android/client/api2/MoshiChatApiTest.kt`:
- Around line 2352-2362: Update the sendEvent test around MoshiChatApi.sendEvent
to use non-empty extraData containing a non-String key, then assert the verified
ChannelApi.sendEvent request contains the corresponding stringified key in
EventRequest.custom. Preserve the existing result assertion and Mockito
verification while covering the new mapping behavior.
🪄 Autofix
Fix all unresolved CodeRabbit comments on this PR:
- Push a commit to this branch (recommended)
- Create a new PR with the fixes
ℹ️ Review info
⚙️ Run configuration
Configuration used: Repository UI
Review profile: CHILL
Plan: Pro Plus
Run ID: e87ef984-4ef9-4e68-88e6-5f26e9f41a1b
📒 Files selected for processing (8)
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/ChannelApi.ktstream-chat-android-client/src/main/java/io/getstream/chat/android/client/parser2/MoshiChatParser.ktstream-chat-android-client/src/main/java/io/getstream/chat/android/client/parser2/adapters/EventRequestAdapter.ktstream-chat-android-client/src/main/java/io/getstream/chat/android/network/models/EventRequest.ktstream-chat-android-client/src/main/java/io/getstream/chat/android/network/models/SendEventRequest.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/EventRequestAdapterTest.kt
…g EventRequest adapter
2856304 to
cc407b0
Compare
|



Goal
Migrate the
sendEventrequest body to the generatedSendEventRequest/EventRequestnetwork models.Part of AND-1291
Implementation
SendEventRequestandEventRequest; remove the hand-writtenSendEventRequest.EventRequestAdapterso the event'scustommap is flattened to the event object root, matching the v1 wire.ChannelApi.sendEvent()and itsMoshiChatApimapper to the generated models.Testing
EventRequestAdapterTestlocks the wire shape, including the flattened custom fields.{"event":{"type":"custom_probe_event","probe_key":"probe_value","probe_num":42}}(extra data at the event root, echoed back by the server), and a built-intyping.startas{"event":{"type":"typing.start"}}.spotlessApply,apiDump(no public-API change),detekt, and the full clienttestDebugUnitTestsuite pass.Summary by CodeRabbit
Bug Fixes
Tests