Skip to content

Build the outgoing message body with the generated MessageRequest model - #6678

Merged
gpunto merged 3 commits into
developfrom
migrate/message-request-body
Sep 3, 2026
Merged

gpunto merged 3 commits into
developfrom
migrate/message-request-body

Conversation

@gpunto

@gpunto gpunto commented Sep 1, 2026 •

Copy link
Copy Markdown
Contributor

Goal

Build the outgoing message body with the generated MessageRequest and delete the hand-written UpstreamMessageDto.

Part of AND-1291

Implementation

  • Point the message field of SendMessageRequest, UpdateMessageRequest and TruncateChannelRequest at MessageRequest, and move the four call sites in MoshiChatApi (send, update, draft create, truncate) onto toMessageRequest(). That mapper, the MessageRequest custom-flattening adapter and the Type adapter were already in place, serving the system-message paths.
  • Add DraftMessage.toMessageRequest(), replacing DraftMessage.toDto(). The draft endpoint takes the same body: CreateDraftRequest.Message is the same payload.MessageRequest struct as sending a message.
  • Delete UpstreamMessageDto, Message.toDto(), UpstreamMessageDtoAdapter and its registration. MessageDtoAdapters.kt becomes DownstreamMessageDtoAdapter.kt, since one declaration remains.
  • Retarget the upstream fixtures and the adapter test to the new shape, keeping the toJson assertions that pin the serialised body.

The request no longer sends args, cid, command, html, pinned_by, shadowed or thread_participants. None are read on this path: html is ignore_if_client_side, shadowed is readonly, cid and pinned_by are utils.JSONPlaceholder in the block the struct comments as legacy fields kept only so the API does not break, and the other three are absent from the struct.

Notes

Two fixture defaults let assertions pass that should not have. randomMessage defaults extraData to empty, so the existing request.custom shouldBeEqualTo message.extraData assertion held even with the mapper dropping custom entirely; randomDraftMessage defaults silent to randomBoolean(), so a mapper hardcoding it would have failed intermittently. Both are now pinned in the tests that depend on them.

Testing

  • Device probe over all four call sites against a throwaway channel: send, update, draft create and truncate were all accepted, with custom data flattened to the root and none of the dropped fields present. poll_id reached the server exactly once at the root, which is worth checking because it is now a declared field while the SDK still passes it through extraData.
  • Mutation checks: dropping custom from either mapper, and hardcoding the draft's silent, each fail a test.
  • The probe also surfaced AND-1473, custom data being dropped when reading a draft back. That is a pre-existing response-side bug, unrelated to this change.

Summary by CodeRabbit

  • Bug Fixes

    • Improved message request serialization for sending, updating, drafting, and truncating messages.
    • Ensured custom fields, mentions, threading, visibility, attachments, and related message properties are mapped consistently.
    • Updated message parsing and request handling to use the current request format.
  • Tests

    • Expanded coverage for message request mapping, custom fields, and serialization behavior.

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

github-actions Bot commented Sep 1, 2026

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

github-actions Bot commented Sep 1, 2026 •

Copy link
Copy Markdown
Contributor

SDK Size Comparison 📏

SDK Before After Difference Status
stream-chat-android-client 6.11 MB 6.11 MB -0.00 MB 🚀
stream-chat-android-ui-components 11.42 MB 11.41 MB -0.01 MB 🚀
stream-chat-android-compose 12.90 MB 12.90 MB -0.00 MB 🚀

@gpunto
gpunto marked this pull request as ready for review September 2, 2026 08:55
@gpunto
gpunto requested a review from a team as a code owner September 2, 2026 08:55
@coderabbitai

coderabbitai Bot commented Sep 2, 2026

Copy link
Copy Markdown

Review Change Stack

No actionable comments were generated in the recent review. 🎉

ℹ️ Recent review info
⚙️ Run configuration

Configuration used: Repository UI

Review profile: CHILL

Plan: Team

Run ID: 2f675469-388d-4964-87ab-dca188ea4f90

📥 Commits

Reviewing files that changed from the base of the PR and between 32addbe and 076b2e2.

📒 Files selected for processing (11)
  • 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/DtoMapping.kt
  • stream-chat-android-client/src/main/java/io/getstream/chat/android/client/api2/model/dto/MessageDtos.kt
  • stream-chat-android-client/src/main/java/io/getstream/chat/android/client/api2/model/requests/SendMessageRequest.kt
  • stream-chat-android-client/src/main/java/io/getstream/chat/android/client/api2/model/requests/TruncateChannelRequest.kt
  • stream-chat-android-client/src/main/java/io/getstream/chat/android/client/api2/model/requests/UpdateMessageRequest.kt
  • stream-chat-android-client/src/main/java/io/getstream/chat/android/client/parser2/MoshiChatParser.kt
  • stream-chat-android-client/src/main/java/io/getstream/chat/android/client/parser2/adapters/DownstreamMessageDtoAdapter.kt
  • stream-chat-android-client/src/test/java/io/getstream/chat/android/client/api2/mapping/DtoMappingTest.kt
  • stream-chat-android-client/src/test/java/io/getstream/chat/android/client/parser2/MessageRequestAdapterTest.kt
  • stream-chat-android-client/src/test/java/io/getstream/chat/android/client/parser2/testdata/MessageDtoTestData.kt
💤 Files with no reviewable changes (3)
  • stream-chat-android-client/src/main/java/io/getstream/chat/android/client/parser2/adapters/DownstreamMessageDtoAdapter.kt
  • stream-chat-android-client/src/main/java/io/getstream/chat/android/client/api2/model/dto/MessageDtos.kt
  • stream-chat-android-client/src/main/java/io/getstream/chat/android/client/parser2/MoshiChatParser.kt

Included review availability: Your plan provides up to 4 included reviews per hour; 3 remain after this review.


Walkthrough

The client replaces UpstreamMessageDto with the generated MessageRequest model for message mappings, API requests, serialization setup, and tests.

Changes

Message request model migration

Layer / File(s) Summary
Request model and mapping migration
stream-chat-android-client/src/main/java/io/getstream/chat/android/client/api2/model/{dto,requests}/*, stream-chat-android-client/src/main/java/io/getstream/chat/android/client/api2/mapping/DtoMapping.kt
Request classes now use MessageRequest. Domain message mappings now produce MessageRequest. UpstreamMessageDto is removed.
API call-site migration
stream-chat-android-client/src/main/java/io/getstream/chat/android/client/api2/MoshiChatApi.kt
Message send, draft, update, and channel truncation operations now call toMessageRequest().
Serialization cleanup and validation
stream-chat-android-client/src/main/java/io/getstream/chat/android/client/parser2/*, stream-chat-android-client/src/test/java/io/getstream/chat/android/client/{api2,parser2}/*
The upstream DTO adapter is removed. Mapping tests and serialization fixtures now validate MessageRequest fields and JSON output.

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

Merge Risk: ⚪ Minimal · up to 076b2

The change moves four existing message operations to the generated request model while preserving custom-data serialization and removing unused fields. Tests and device probes cover the updated payloads, so no actionable merge-blocking risk remains beyond normal checks and review.

Suggested reviewers: velikovpetar

Poem

A rabbit maps each message bright
To request models, clean and light
Old DTO shadows fade away
Tests pin custom fields in place
Moshi hops along the updated route

🚥 Pre-merge checks | ✅ 4 | ❌ 1

❌ Failed checks (1 warning)

Check name Status Explanation Resolution
Docstring Coverage ⚠️ Warning Docstring coverage is 16.67% which is insufficient. The required threshold is 80.00%. Docstring coverage is scoped to functions touched by this diff. Analyzed 18 functions across 8 files. 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 summarizes the primary change: outgoing message bodies now use the generated MessageRequest model.
Description check ✅ Passed The description includes the goal, implementation details, testing results, issue references, and relevant behavioral changes. The UI Changes section is not applicable to this SDK model and request-bo…
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.
Full details: Description check

Explanation

The description includes the goal, implementation details, testing results, issue references, and relevant behavioral changes. The UI Changes section is not applicable to this SDK model and request-body change, although the contributor and reviewer checklist items remain unchecked.

  • Fix all pre-merge checks with AI
✨ Finishing Touches 💡 2
📝 Generate docstrings 💡
  • Create stacked PR
  • Commit on current branch
🛠️ Fix failing CI checks 💡
  • Create stacked PR
  • Commit on current branch
🧪 Generate unit tests (beta)
  • Create PR with unit tests
  • Commit unit tests in branch migrate/message-request-body

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.

@gpunto
gpunto enabled auto-merge September 2, 2026 09:20

@andremion andremion left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Looks good. Two coverage notes and a couple of small things inline.

@sonarqubecloud

sonarqubecloud Bot commented Sep 3, 2026

Copy link
Copy Markdown

@gpunto
gpunto added this pull request to the merge queue Sep 3, 2026
Merged via the queue into develop with commit 0549972 Sep 3, 2026
19 checks passed
@gpunto
gpunto deleted the migrate/message-request-body branch September 3, 2026 17:47
@stream-public-bot stream-public-bot added the released Included in a release label Sep 10, 2026
@stream-public-bot

Copy link
Copy Markdown
Contributor

🚀 Available in v7.11.0

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

pr:internal Internal changes / housekeeping released Included in a release

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants