Skip to content

Migrate the new message event to the generated event model - #6790

Merged
gpunto merged 2 commits into
developfrom
migrate/message-new-event
Oct 8, 2026
Merged

gpunto merged 2 commits into
developfrom
migrate/message-new-event

Conversation

@gpunto

@gpunto gpunto commented Oct 8, 2026 •

Copy link
Copy Markdown
Contributor

Goal

Parse the message.new event with the generated event model.

Part of AND-1291

Implementation

  • Vendor the generated MessageNewEvent and delete NewMessageEventDto and DownstreamChannelCustomDto (ChannelDtos.kt is renamed DownstreamChannelDto.kt, its only class).
  • The adapter requires the cid and the user, which the domain event needs. The channel type and id come from the cid, and the message's channel info takes the channel name and image from channel_custom.
  • message_id and watcher_count are nullable in the vendored model: backends before v239.47.0 replay message.new on /sync without them, and the spec marks them required. A missing watcher count maps to 0 and missing unread counts stay 0, as before; the mapper never reads message_id. The model comment says when to drop the patch.
  • The opt-in fast parser is unchanged.

Testing

NewMessageEventParsingTest now compares the fast parser with the generated path and they produce identical events. Its fixtures carry the fields the backend always sends, through a WireShape test helper shared with MessageResponseParityTest. Where the two paths deliberately differ, the generated path takes the channel type and id from the cid and treats an event without a type as unknown. The mapping tests cover every field and the replayed shape.

On a device: sent a message with custom data in a channel with a name and an image, a thread reply, and channel update and truncate system messages (the truncate event carries the channel). Every domain field was set, custom data round-tripped, and /sync parsed the replayed event.

🤖 Generated with Claude Code

Summary by CodeRabbit

  • Bug Fixes
    • Improved parsing of new-message events to provide channel details from the event and handle absent optional counts and channel metadata more consistently.
    • Updated event handling to better support message payloads with missing optional fields, including those received during sync and replay.
    • Added coverage for event parsing across populated, minimal, and replay scenarios.

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

github-actions Bot commented Oct 8, 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 Oct 8, 2026 •

Copy link
Copy Markdown
Contributor

SDK Size Comparison 📏

SDK Before After Difference Status
stream-chat-android-client 6.22 MB 6.21 MB -0.00 MB 🚀
stream-chat-android-ui-components 11.53 MB 11.52 MB -0.01 MB 🚀
stream-chat-android-compose 13.20 MB 13.19 MB -0.00 MB 🚀

@gpunto
gpunto marked this pull request as ready for review October 8, 2026 10:36
@gpunto
gpunto requested a review from a team as a code owner October 8, 2026 10:36
@gpunto
gpunto enabled auto-merge October 8, 2026 10:36
@coderabbitai

coderabbitai Bot commented Oct 8, 2026

Copy link
Copy Markdown

Review in Change Stack →

No actionable comments were generated in the recent review. 🎉

ℹ️ Recent review info
⚙️ Run configuration
  • Configuration used: Repository UI
  • Review profile: CHILL
  • Plan: Advanced
  • Run ID: 081d395f-e660-42f4-b9d6-592f69ba5bba
📥 Commits

Reviewing files that changed from the base of the PR and between 76477fd and 10c4062.

📒 Files selected for processing (13)
  • stream-chat-android-client/src/main/java/io/getstream/chat/android/client/api2/mapping/EventMapping.kt
  • stream-chat-android-client/src/main/java/io/getstream/chat/android/client/api2/model/dto/DownstreamChannelDto.kt
  • stream-chat-android-client/src/main/java/io/getstream/chat/android/client/api2/model/dto/EventDtos.kt
  • stream-chat-android-client/src/main/java/io/getstream/chat/android/client/parser2/adapters/EventAdapter.kt
  • stream-chat-android-client/src/main/java/io/getstream/chat/android/network/models/MessageNewEvent.kt
  • stream-chat-android-client/src/test/java/io/getstream/chat/android/client/EventChatJsonProvider.kt
  • stream-chat-android-client/src/test/java/io/getstream/chat/android/client/api2/mapping/EventMappingTestArguments.kt
  • stream-chat-android-client/src/test/java/io/getstream/chat/android/client/parser/EventArguments.kt
  • stream-chat-android-client/src/test/java/io/getstream/chat/android/client/parser2/DirectEventParserTest.kt
  • stream-chat-android-client/src/test/java/io/getstream/chat/android/client/parser2/MessageResponseParityTest.kt
  • stream-chat-android-client/src/test/java/io/getstream/chat/android/client/parser2/NewMessageEventParsingTest.kt
  • stream-chat-android-client/src/test/java/io/getstream/chat/android/client/parser2/testdata/NewMessageEventTestData.kt
  • stream-chat-android-client/src/test/java/io/getstream/chat/android/client/parser2/testdata/WireShape.kt
💤 Files with no reviewable changes (2)
  • stream-chat-android-client/src/main/java/io/getstream/chat/android/client/api2/model/dto/EventDtos.kt
  • stream-chat-android-client/src/main/java/io/getstream/chat/android/client/api2/model/dto/DownstreamChannelDto.kt

Included review availability: This review used your included allowance. Your plan provides up to 4 included reviews per hour; 1 remain after this review.


Walkthrough

The message.new event parser and domain mapper now use the generated MessageNewEvent model instead of the legacy DTO. Test fixtures and assertions were updated to cover generated event parsing, channel mapping, optional fields, and shared JSON shaping.

Changes

Generated message.new event mapping

Layer / File(s) Summary
Parse and map generated events
stream-chat-android-client/src/main/java/io/getstream/chat/android/network/models/MessageNewEvent.kt, stream-chat-android-client/src/main/java/io/getstream/chat/android/client/parser2/adapters/EventAdapter.kt, stream-chat-android-client/src/main/java/io/getstream/chat/android/client/api2/mapping/EventMapping.kt, stream-chat-android-client/src/main/java/io/getstream/chat/android/client/api2/model/dto/*
MessageNewEvent provides the generated event model. The event adapter and mapper use it to produce NewMessageEvent, deriving channel type and ID from the CID and defaulting missing counts to zero. The legacy new-message DTOs were removed.
Shape parser test fixtures
stream-chat-android-client/src/test/java/io/getstream/chat/android/client/parser2/testdata/WireShape.kt, stream-chat-android-client/src/test/java/io/getstream/chat/android/client/parser2/testdata/NewMessageEventTestData.kt, stream-chat-android-client/src/test/java/io/getstream/chat/android/client/parser2/MessageResponseParityTest.kt
WireShape normalizes message and user fixture fields and removes channel data from message payloads. Event fixtures and message response parity tests use the shared shaping helpers.
Verify generated event behavior
stream-chat-android-client/src/test/java/io/getstream/chat/android/client/EventChatJsonProvider.kt, stream-chat-android-client/src/test/java/io/getstream/chat/android/client/api2/mapping/EventMappingTestArguments.kt, stream-chat-android-client/src/test/java/io/getstream/chat/android/client/parser/EventArguments.kt, stream-chat-android-client/src/test/java/io/getstream/chat/android/client/parser2/*Event*Test.kt
Event fixtures and tests use the generated model and ChatEventDto. Assertions cover channel metadata, defaults for omitted counts, required fields, and parsing parity.

Priority: ➖ Normal

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

Change: Refactor

Sequence Diagram(s)

sequenceDiagram
  participant EventAdapter
  participant MessageNewEvent
  participant EventMapping
  participant NewMessageEvent
  EventAdapter->>MessageNewEvent: parse message.new JSON
  MessageNewEvent->>EventMapping: provide generated event fields
  EventMapping->>NewMessageEvent: map message and channel information
Loading

Suggested reviewers: velikovpetar

Merge Risk: ⚪ Minimal · up to 10c40

This change moves message.new parsing to the generated event model, and no merge-blocking issue was found. Replayed events that omit some fields are handled with safe defaults.

🚥 Pre-merge checks | ✅ 4 | ❌ 1

❌ Failed checks (1 warning)

Check name Status Explanation Resolution
Docstring Coverage ⚠️ Warning Docstring coverage is 33.33% which is insufficient. The required threshold is 80.00%. Docstring coverage is scoped to functions touched by this diff. Analyzed 39 functions across 11 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 and concisely describes the primary change: migrating the new message event to the generated event model.
Description check ✅ Passed The description includes complete Goal, Implementation, and Testing sections. It explains the migration, compatibility behavior, test coverage, and device validation. UI details, checklist items, revi…
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.
  • Fix all pre-merge checks with AI
✨ Finishing Touches 💡 1
📝 Generate docstrings 💡
  • Commit to this branch
  • Create a new PR
🧪 Generate unit tests (beta)
  • Commit to this branch
  • Create a new PR
  • Autopilot · Keep fixing CodeRabbit findings and required CI, and resolving merge conflicts

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

A rabbit checks the message stream,
New fields arrive and join the team.
Channel names and counts take shape,
Old DTOs hop out of the gate.
Tests keep watch on every leap.

Comment @coderabbitai help to get the list of available commands.

@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. One small nit inline.

@gpunto
gpunto force-pushed the migrate/message-new-event branch from 10c4062 to f7e17d2 Compare October 8, 2026 12:40
@sonarqubecloud

sonarqubecloud Bot commented Oct 8, 2026

Copy link
Copy Markdown

@gpunto
gpunto added this pull request to the merge queue Oct 8, 2026
Merged via the queue into develop with commit 4e63aa2 Oct 8, 2026
19 checks passed
@gpunto
gpunto deleted the migrate/message-new-event branch October 8, 2026 14:44
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.

2 participants