Skip to content

Migrate mark-delivered, send-action, and partial-update-member request bodies to generated models#6569

Draft
gpunto wants to merge 4 commits into
developfrom
migrate/request-bodies-1
Draft

Migrate mark-delivered, send-action, and partial-update-member request bodies to generated models#6569
gpunto wants to merge 4 commits into
developfrom
migrate/request-bodies-1

Conversation

@gpunto

@gpunto gpunto commented Jul 10, 2026

Copy link
Copy Markdown
Contributor

Goal

Migrate three small request bodies to their generated network.models types. Batched together as they're each single-model swaps of the same shape. Part of the incremental OpenAPI model migration.

Part of AND-1291

Implementation

Each endpoint swaps its hand-written request DTO for the generated model (real names, no migration aliases); no wire-shape changes.

  • markDelivered (POST /channels/delivered) -> generated MarkDeliveredRequest + DeliveredMessagePayload. MarkDeliveredRequest.create(...) inlined as messages.map { DeliveredMessagePayload(cid = it.cid, id = it.id) }. Dropped a redundant same-package qualifier on the nested type to fit detekt's line limit.
  • sendAction (POST /messages/{id}/action) -> generated MessageActionRequest (only form_data; the backend struct reads the message id from the path and ignores channel_id/type, verified against /chat).
  • partialUpdateMember (PATCH /channels/{type}/{id}/member/{user_id}) -> generated UpdateMemberPartialRequest. Call site switched to named args because the generated model orders fields unset, set (positional would swap them).

Testing

  • spotlessApply, apiCheck (no API drift), detekt, and the client testDebugUnitTest suite pass.
  • Each endpoint device-verified on the wire before batching:
    • markDelivered: real inbound delivery fired POST /channels/delivered {"latest_delivered_messages":[{"cid","id"}]} -> 201.
    • sendAction: giphy shuffle/send sent {"form_data":{"image_action":"…"}} -> 2xx.
    • partialUpdateMember: set/unset a member custom field round-tripped (probe=v1 -> probe=null) -> 200.

Summary by CodeRabbit

  • Improvements
    • Updated message delivery reporting to use the latest delivered message payload format.
    • Improved partial member updates with clearer handling of fields to set or remove.
    • Updated message action requests to consistently transmit form data as text values.
  • Compatibility
    • Standardized request handling across chat, channel, and message operations for more reliable network communication.

@gpunto gpunto added the pr:internal Internal changes / housekeeping label Jul 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.94 MB 5.94 MB 0.00 MB 🟢
stream-chat-android-ui-components 11.21 MB 11.20 MB -0.01 MB 🚀
stream-chat-android-compose 12.68 MB 12.68 MB 0.00 MB 🟢

@gpunto gpunto marked this pull request as ready for review July 10, 2026 15:27
@gpunto gpunto requested a review from a team as a code owner July 10, 2026 15:27
@sonarqubecloud

Copy link
Copy Markdown

Quality Gate Failed Quality Gate failed

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

See analysis details on SonarQube Cloud

@coderabbitai

coderabbitai Bot commented Jul 10, 2026

Copy link
Copy Markdown

Review Change Stack

Walkthrough

Request models for delivery, member updates, and message actions were moved to the network layer. API2 endpoints and request construction now use the new models, with tests updated for the revised payload shapes and string form-data mapping.

Changes

Network request model migration

Layer / File(s) Summary
Network request contracts
stream-chat-android-client/src/main/java/io/getstream/chat/android/network/models/*
Adds Moshi models for delivered messages, partial member updates, and message actions with updated JSON field names and types.
API2 request wiring
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/*
Builds the new request models, maps delivered messages and action form data, and updates Retrofit endpoint parameter types.
Request mapping tests
stream-chat-android-client/src/test/java/io/getstream/chat/android/client/api2/MoshiChatApiTest.kt
Updates delivery and message-action expectations to use the new request models and payload mappings.

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

Suggested reviewers: andremion

Poem

I’m a rabbit with models tucked neat,
Mapping each payload from ears to feet.
Delivered hops now travel in line,
Actions turn strings and serialize fine.
The tests twitch their noses: all green!

🚥 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
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.
Title check ✅ Passed The title clearly summarizes the main change: migrating three request bodies to generated models.
Description check ✅ Passed The required Goal, Implementation, and Testing sections are present and detailed; optional UI/checklist/GIF sections are omitted.
✨ Finishing Touches
📝 Generate docstrings
  • Create stacked PR
  • Commit on current branch
🧪 Generate unit tests (beta)
  • Create PR with unit tests
  • Commit unit tests in branch migrate/request-bodies-1

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.

Caution

Some comments are outside the diff and can’t be posted inline due to platform limitations.

⚠️ Outside diff range comments (1)
stream-chat-android-client/src/main/java/io/getstream/chat/android/client/api2/MoshiChatApi.kt (1)

1340-1349: 🗄️ Data Integrity & Integration | 🟡 Minor | ⚡ Quick win

Avoid coercing formData here. In MoshiChatApi.kt:1340-1344, SendActionRequest.formData is Map<Any, Any>, so .toString() changes any non-string values before serialization. Narrow the domain type to Map<String, String> or preserve the original values if that payload shape matters.

🤖 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/client/api2/MoshiChatApi.kt`
around lines 1340 - 1349, Update sendAction to avoid converting formData keys
and values with toString(). Narrow SendActionRequest.formData to Map<String,
String> and pass it directly into MessageActionRequest, or change the API model
to preserve non-string values when they are required by the payload.
🤖 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.

Outside diff comments:
In
`@stream-chat-android-client/src/main/java/io/getstream/chat/android/client/api2/MoshiChatApi.kt`:
- Around line 1340-1349: Update sendAction to avoid converting formData keys and
values with toString(). Narrow SendActionRequest.formData to Map<String, String>
and pass it directly into MessageActionRequest, or change the API model to
preserve non-string values when they are required by the payload.

ℹ️ Review info
⚙️ Run configuration

Configuration used: Repository UI

Review profile: CHILL

Plan: Pro

Run ID: 940c67a7-284d-49ad-bc50-29a46c7eb907

📥 Commits

Reviewing files that changed from the base of the PR and between 71cfe27 and 6f05cf1.

📒 Files selected for processing (9)
  • 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/ChannelApi.kt
  • stream-chat-android-client/src/main/java/io/getstream/chat/android/client/api2/endpoint/MessageApi.kt
  • stream-chat-android-client/src/main/java/io/getstream/chat/android/client/api2/model/requests/MarkDeliveredRequest.kt
  • stream-chat-android-client/src/main/java/io/getstream/chat/android/network/models/DeliveredMessagePayload.kt
  • stream-chat-android-client/src/main/java/io/getstream/chat/android/network/models/MarkDeliveredRequest.kt
  • stream-chat-android-client/src/main/java/io/getstream/chat/android/network/models/MessageActionRequest.kt
  • stream-chat-android-client/src/main/java/io/getstream/chat/android/network/models/UpdateMemberPartialRequest.kt
  • stream-chat-android-client/src/test/java/io/getstream/chat/android/client/api2/MoshiChatApiTest.kt
💤 Files with no reviewable changes (1)
  • stream-chat-android-client/src/main/java/io/getstream/chat/android/client/api2/model/requests/MarkDeliveredRequest.kt

@gpunto gpunto marked this pull request as draft July 10, 2026 15:34
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