Migrate the user on user, read and delivery events to the generated user field models by gpunto · Pull Request #6724 · GetStream/stream-chat-android · GitHub
Skip to content

Migrate the user on user, read and delivery events to the generated user field models - #6724

Merged
gpunto merged 5 commits into
developfrom
migrate/user-events
Sep 24, 2026
Merged

gpunto merged 5 commits into
developfrom
migrate/user-events

Conversation

@gpunto

@gpunto gpunto commented Sep 23, 2026 •

Copy link
Copy Markdown
Contributor

Goal

Parse the user carried by the user, read and delivery events with the generated models the backend
serializes them from.

Part of AND-1291

Implementation

  • Point user on user.updated at UserResponsePrivacyFields, and on user.presence.changed,
    user.deleted, user.watching.start/stop, the channel and global ban/unban events,
    message.delivered, notification.mark_read (per channel and mark-all), notification.mark_unread and
    user.messages.deleted at UserResponseCommonFields. These match the structs the backend embeds in each
    event. Vendors both models.
  • Add their mappers to User, and collecting adapters so the flattened custom fields land in custom.
  • Keep deleted_at and revoke_tokens_issued_before in extraData as well. Both models declare them and
    the domain has no property for either.
  • Read devices out of the custom data into the typed devices, and drop it from extraData.

Notes

Neither model declares devices, but event users can carry a device list as custom data, in the request
shape. The previous DTO declared the key, so it always ended up in User.devices. Without promoting it, it
would surface in extraData and, because user.updated merges into the current user, in the current user's
extraData too.

language goes from nullable to required. It is a plain non-pointer tag on the shared user fields, so it is
always sent. The event test fixtures now use the shapes these events actually carry, without the own-user
state (devices, mutes, unread counts) the previous shared fixture had.

On the read and delivery events the backend embeds the user as optional (json:"user,omitempty"), while
the DTOs keep it required. In practice the reader is always set: the mark-all-read constructor dereferences
it directly. Keeping it required matches the previous behavior.

The mock server does not emit the user events; it builds notification.mark_unread from a recorded user
that has every required field.

Testing

Mutation sweep over both mappers: zero survivors. A parsing test feeds whole event payloads through the
parser to cover the adapters, the kept keys and the devices promotion end to end.

Device-probed user.updated, user.watching.start, notification.mark_unread, notification.mark_read and
mark-all-read with a custom field set on the user: language, the custom field and 16 devices came through
the typed fields, with no devices key in the event user's or the current user's extraData. Presence, ban,
delete, message.delivered and user.messages.deleted are not reachable from a single client and are
covered by the parsing tests.

Summary by CodeRabbit

  • Bug Fixes
    • User information in chat events is now mapped more accurately, including privacy settings and device details.
    • Additional user data, such as deletion and token-revocation details, remains available in event data.

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

Copy link
Copy Markdown
Contributor

@gpunto gpunto changed the title Parse the user on user, read and delivery events with the generated user field models Migrate the user on user, read and delivery events to the generated user field models Sep 23, 2026
@github-actions

github-actions Bot commented Sep 23, 2026 •

Copy link
Copy Markdown
Contributor

SDK Size Comparison 📏

SDK Before After Difference Status
stream-chat-android-client 6.09 MB 6.09 MB 0.01 MB 🟢
stream-chat-android-ui-components 11.40 MB 11.41 MB 0.01 MB 🟢
stream-chat-android-compose 13.07 MB 13.07 MB 0.01 MB 🟢

@gpunto
gpunto marked this pull request as ready for review September 23, 2026 15:36
@gpunto
gpunto requested a review from a team as a code owner September 23, 2026 15:36
@coderabbitai

coderabbitai Bot commented Sep 23, 2026

Copy link
Copy Markdown

Review in Change Stack →

Navigate logical layers of code changes, visualize relationships, and explore their blast radius.

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: 632fc8c1-0d5f-45b6-b22e-692be2bdbd7b

📥 Commits

Reviewing files that changed from the base of the PR and between d9f16d3 and b7da720.

📒 Files selected for processing (12)
  • stream-chat-android-client/src/main/java/io/getstream/chat/android/client/api2/mapping/DomainMapping.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/MoshiChatParser.kt
  • stream-chat-android-client/src/main/java/io/getstream/chat/android/client/parser2/adapters/EventUserAdapters.kt
  • stream-chat-android-client/src/main/java/io/getstream/chat/android/network/models/UserResponseCommonFields.kt
  • stream-chat-android-client/src/main/java/io/getstream/chat/android/network/models/UserResponsePrivacyFields.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/Mother.kt
  • stream-chat-android-client/src/test/java/io/getstream/chat/android/client/api2/mapping/DomainMappingTest.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/EventUserParsingTest.kt

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


Walkthrough

Event DTOs now use common user response fields for most user events and privacy fields for user.updated. Moshi adapters decode these shapes, and domain mapping converts them to User, including device data extracted from custom fields.

Changes

Event user response mapping

Layer / File(s) Summary
Event response shapes and DTOs
stream-chat-android-client/src/main/java/io/getstream/chat/android/network/models/UserResponse*.kt, stream-chat-android-client/src/main/java/io/getstream/chat/android/client/api2/model/dto/EventDtos.kt
Added common-fields and privacy-fields response models. User event DTOs now use the relevant response shape.
Event-user decoding and domain mapping
stream-chat-android-client/src/main/java/io/getstream/chat/android/client/parser2/adapters/EventUserAdapters.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/api2/mapping/DomainMapping.kt
Registered adapters for the event user shapes. Added mappings to User, including device extraction from custom data and retention of specified extra-data keys.
Fixtures and mapping tests
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/Mother.kt, stream-chat-android-client/src/test/java/io/getstream/chat/android/client/api2/mapping/*, 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/EventUserParsingTest.kt
Updated event fixtures to use common or privacy user fields. Added tests for field mapping, device conversion, extra-data retention, and event parsing.

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

Sequence Diagram(s)

sequenceDiagram
  participant EventPayload
  participant MoshiChatParser
  participant EventUserAdapter
  participant EventDto
  participant DomainMapping
  EventPayload->>MoshiChatParser: Parse event JSON
  MoshiChatParser->>EventUserAdapter: Deserialize event user
  EventUserAdapter-->>EventDto: Provide common or privacy response
  EventDto->>DomainMapping: Convert response user
  DomainMapping-->>EventDto: Return domain User
Loading

Suggested reviewers: velikovpetar

Merge Risk: ⚪ Minimal · up to b7da7

User, read, delivery, ban, and watching events now parse their embedded user with shapes that match the backend's event user fields. Device data moves into the typed field, and the remaining custom fields are preserved. No concrete defect was identified, so the change appears ready to merge after normal checks.

🚥 Pre-merge checks | ✅ 4 | ❌ 1

❌ Failed checks (1 warning)

Check name Status Explanation Resolution
Docstring Coverage ⚠️ Warning Docstring coverage is 11.90% which is insufficient. The required threshold is 80.00%. Docstring coverage is scoped to functions touched by this diff. Analyzed 42 functions across 12 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 identifies the main change: migrating event user payloads to generated user field models for user, read, and delivery events. It is specific and related to the changeset.
Description check ✅ Passed The description includes the goal, implementation details, important compatibility notes, and testing evidence. UI sections, checklists, and the GIF are not completed, but they are not critical for th…
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

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 fields in rows,
Then follows where each user goes.
Devices hop from custom data,
While extra keys stay in the stack.
The parser turns the JSON round,
And maps a User without a sound.

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 optional nit inline.

@gpunto
gpunto enabled auto-merge September 24, 2026 10:00
@gpunto
gpunto force-pushed the migrate/user-events branch from b7da720 to bab6104 Compare September 24, 2026 11:33
@sonarqubecloud

Copy link
Copy Markdown

@gpunto
gpunto added this pull request to the merge queue Sep 24, 2026
@gpunto
gpunto removed this pull request from the merge queue due to a manual request Sep 24, 2026
@gpunto
gpunto added this pull request to the merge queue Sep 24, 2026
@github-merge-queue
github-merge-queue Bot removed this pull request from the merge queue due to failed status checks Sep 24, 2026
@gpunto
gpunto added this pull request to the merge queue Sep 24, 2026
Merged via the queue into develop with commit 802d7b4 Sep 24, 2026
19 checks passed
@gpunto
gpunto deleted the migrate/user-events branch September 24, 2026 15:37
@stream-public-bot stream-public-bot added the released Included in a release label Sep 30, 2026
@stream-public-bot

Copy link
Copy Markdown
Contributor

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