Skip to content

Migrate the message poll to the generated PollResponseData model - #6680

Open
gpunto wants to merge 3 commits into
developfrom
migrate/message-poll
Open

Migrate the message poll to the generated PollResponseData model#6680
gpunto wants to merge 3 commits into
developfrom
migrate/message-poll

Conversation

@gpunto

@gpunto gpunto commented Sep 2, 2026

Copy link
Copy Markdown
Contributor

Goal

Parse the poll embedded in a message with the generated PollResponseData.

Part of AND-1291

Implementation

  • Point DownstreamMessageDto.poll at PollResponseData, the model the poll endpoints already use, and follow the field rename in lastUpdateTime(). PollResponseData.toDomain() was already in place, so no mapping code is added.
  • Enrich the nested vote, answer and creator users in the message fixture. The generated UserResponse requires created_at, updated_at and language, and the fixture carried only id, role, banned and online.

DownstreamPollDto stays for the poll events, which still parse it.

Notes

The message carries Poll *commonpayloads.PollResponseData, the same struct the poll endpoints return, and created_at, updated_at and language are non-omitempty on UserResponseCommonFields. So the wire always sends them for a nested poll user and the old fixture was the unrealistic part.

The two paths swap strictness on three keys. voting_visibility was String? and defaulted to PUBLIC; it is required on PollResponseData, so a poll that omits it now throws on the DTO path while PollAdapter still defaults it. options and own_votes go the other way, defaulting to empty on the DTO path while PollAdapter still throws. None can fire in practice: all three are plain non-omitempty tags on the Go response struct.

A custom key with a null value no longer reaches Poll.extraData. The DTO path used to keep it and the direct path already dropped it, so this aligns them.

Testing

  • Device probe: created a poll with custom data on the poll and on one option, sent it, cast a vote and an answer, then read the message back through getMessage and queryChannels. Both custom values round-tripped, config was preserved, and every nested user (creator, votes, own votes, answers) carried the three required fields.
  • Mutation checks: nulling message.poll, and dropping poll.updatedAt from lastUpdateTime, each fail 6 tests.
  • MessageParsingTest gains a case for poll and option custom data inlined on the message, which also pins the null-valued key being dropped on both paths.

Summary by CodeRabbit

  • Bug Fixes
    • Poll messages now correctly reflect the poll’s latest update time.
    • Poll data is mapped consistently, preserving custom poll information in message details.
    • Poll-related user information, including creator, voters, and respondents, is handled more completely.
  • Tests
    • Expanded coverage for poll custom data, optional message properties, timestamps, and user metadata.

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

github-actions Bot commented Sep 2, 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 2, 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.41 MB 11.41 MB 0.00 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 4, 2026 14:22
@gpunto
gpunto requested a review from a team as a code owner September 4, 2026 14:22
@gpunto
gpunto enabled auto-merge September 4, 2026 14:23
@coderabbitai

coderabbitai Bot commented Sep 4, 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: 089a3412-3f1b-474c-86fa-9215121ab769

📥 Commits

Reviewing files that changed from the base of the PR and between 8e661ce and bc5cf6a.

📒 Files selected for processing (5)
  • 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/MessageDtos.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/parser2/testdata/MessageTestData.kt

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


Walkthrough

The message DTO now uses PollResponseData. Poll timestamp mapping reads updatedAt. Tests cover custom poll data, optional message properties, and enriched poll user fields.

Changes

Poll mapping

Layer / File(s) Summary
Poll response contract and timestamp mapping
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/mapping/DomainMapping.kt
DownstreamMessageDto.poll now uses PollResponseData. Message update timestamps now use poll.updatedAt.
Poll mapping validation
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/parser2/testdata/MessageTestData.kt
Test helpers and fixtures use PollResponseData. Tests verify custom data filtering and enriched poll user fields.

Estimated code review effort: 2 (Simple) | ~10 minutes

Merge Risk: ⚪ Minimal · up to bc5cf

Message poll parsing now uses the generated response model and its updated timestamp while preserving domain poll mapping and custom data behavior. The supplied coverage and current implementation alignment indicate no remaining merge-blocking risk.

Suggested reviewers: aleksandar-apostolov

Poem

A rabbit checked the poll at dawn
Its newest timestamp now lives on
Custom data hopped in line
Null fields vanished, neat and fine
The tests now greet the change with song

🚥 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%. Docstring coverage is scoped to functions touched by this diff. Analyzed 5 functions across 5 files. 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 identifies the primary change: migrating message poll parsing to the generated PollResponseData model.
Description check ✅ Passed The description clearly explains the goal, implementation, retained DownstreamPollDto usage, behavioral differences, and testing. The UI, GIF, and checklist sections are not included, but they are non…
  • Fix all pre-merge checks with AI
✨ Finishing Touches 💡 1
📝 Generate docstrings 💡
  • Create stacked PR
  • Commit on current branch
🧪 Generate unit tests (beta)
  • Create PR with unit tests
  • Commit unit tests in branch migrate/message-poll

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.

@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 note inline on the nullability change and two optional ones.

val moderation_details: DownstreamModerationDetailsDto? = null, // Used for Moderation V1
val moderation: DownstreamModerationDto? = null, // Used for Moderation V2
val poll: DownstreamPollDto? = null,
val poll: PollResponseData? = null,

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.

voting_visibility goes from optional to required with this type. It was String? on DownstreamPollDto and it's String on PollResponseData, so a message whose poll omits the key used to default to PUBLIC and now the DTO path throws JsonDataException, which fails the whole message. The direct MessageAdapter still defaults it, so the two paths disagree on that input.

The backend always serializes the key, so it shouldn't fire in practice. Any reason not to note it in the Notes next to the created_at / updated_at / language bit? options and own_votes went the other way, lenient on the DTO path now and still strict in PollAdapter.

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

Good catch, and confirmed: voting_visibility is required on PollResponseData while PollAdapter still defaults a missing key to PUBLIC. Noted in the Notes, along with options and own_votes swapping strictness the other way. All three are plain non-omitempty tags on the Go response struct, so none can fire in practice.


val poll = with(sut) { response.toDomain() }

// `absent` is dropped: the domain map does not hold null values.

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.

Small thing: this is a behaviour change for message polls too, not only a property of the new model. On develop a null-valued custom key stayed in Poll.extraData on the DTO path and got dropped on the direct path, so the two disagreed. mapNotNull fixes that.

Could be worth a line in the PR body so it reaches the release notes?

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

Right, it changes the DTO path too. Added to the Notes: a null-valued custom key used to stay in Poll.extraData on the DTO path and was already dropped on the direct path, so this aligns them.

}
],
"created_by": {"id": "user-1", "role": "user", "banned": false, "online": true},
"created_by": {"id": "user-1", "role": "user", "banned": false, "online": true, "created_at": "2020-01-01T00:00:00.000Z", "updated_at": "2020-01-01T00:00:00.000Z", "language": "en"},

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.

Could be nice: the poll here carries no custom keys, so assertBothPaths never compares poll or option extraData across the two parsers. PollResponseParsingTest covers the endpoint response but not the message.

Maybe add inlined custom keys on the poll and one option, like jsonWithMemberCustomInlined does for members? I tried it locally and both paths already agree, so it passes as is. Not blocking.

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

Done in 4f390fa. The poll in jsonAllFields now carries an inlined custom key and option-1 carries one too, with a focused test asserting both land on the domain fields and option-2 stays empty. The poll also carries a null-valued key, so the same test pins the drop from the other comment.

@sonarqubecloud

sonarqubecloud Bot commented Sep 7, 2026

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.

2 participants