Skip to content

Migrate thread participants to the generated ThreadParticipant model - #6620

Draft
gpunto wants to merge 2 commits into
developfrom
migrate/thread-participants
Draft

Migrate thread participants to the generated ThreadParticipant model#6620
gpunto wants to merge 2 commits into
developfrom
migrate/thread-participants

Conversation

@gpunto

@gpunto gpunto commented Aug 6, 2026

Copy link
Copy Markdown
Contributor

Goal

Migrate thread participants from the hand-written DownstreamThreadParticipantDto to the generated ThreadParticipant model, together with the null-collection handling the v1 endpoints require for it to parse.

Part of AND-1291

Implementation

The generated models come from the v2 spec, whose encoder writes nil Go maps and slices as {} and [], so their collection properties are non-null. We call the v1 endpoints, whose encoder writes null instead: POST /threads sends "custom": null on every thread_participants entry.

  • Add NullCollectionsAsEmptyFactory, which reads an explicit null as an empty collection for the non-null List and Map properties of the generated network models. It only claims classes in the network.models package that declare such a property, and is registered last so the model-specific adapters keep precedence and delegate into it.
  • Add the generated ThreadParticipant and UserResponse, plus UserResponseAdapter for the user's flattened custom data; remove the hand-written DownstreamThreadParticipantDto.
  • Retype thread_participants on DownstreamThreadDto and DownstreamThreadInfoDto and map it to the domain ThreadParticipant in DomainMapping. The message-level thread_participants is a list of users rather than participants, so DownstreamMessageDto is unchanged.

Testing

  • NullCollectionsAsEmptyFactoryTest: an explicit null becomes an empty collection, an absent key still falls back to the model default, populated collections are read unchanged, and hand-written DTOs are left alone.
  • ThreadParticipantParsingTest parses a payload captured from POST /threads. Removing the factory registration makes it fail with Non-null value 'custom' was null at $.custom.
  • Device-probed queryThreads on the wire: 10 threads and 22 participants parsed, the parsed count matched participantCount on every thread, and per-user custom data was collected correctly.
  • Checked in a minified release build with R8 full mode: the factory's Kotlin reflection survives obfuscation, so no additional consumer proguard rule is needed.
  • spotlessApply, detekt, apiCheck (no public API change) and the full stream-chat-android-client unit test suite.

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

github-actions Bot commented Aug 6, 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 Aug 6, 2026

Copy link
Copy Markdown
Contributor

SDK Size Comparison 📏

SDK Before After Difference Status
stream-chat-android-client 5.96 MB 5.97 MB 0.01 MB 🟢
stream-chat-android-ui-components 11.26 MB 11.27 MB 0.01 MB 🟢
stream-chat-android-compose 12.74 MB 12.75 MB 0.01 MB 🟢

@gpunto
gpunto force-pushed the migrate/thread-participants branch from cdb400b to 6cde0aa Compare August 10, 2026 15:03
@sonarqubecloud

Copy link
Copy Markdown

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