Skip to content

Migrate the poll events to the generated poll event models - #6744

Merged
gpunto merged 2 commits into
developfrom
migrate/poll-events
Sep 29, 2026
Merged

gpunto merged 2 commits into
developfrom
migrate/poll-events

Conversation

@gpunto

@gpunto gpunto commented Sep 28, 2026 •

Copy link
Copy Markdown
Contributor

Goal

Parse the poll events with the generated event models, keeping each event's created_at exactly as the
server sent it.

Part of AND-1291

Implementation

  • Vendor the generated poll events, WSClientEvent, the WSEvent interface, and the generated
    ExactDate with its adapter (the parsed date plus the raw string).
  • EventAdapter parses poll.closed, poll.updated, poll.deleted, poll.vote_casted,
    poll.vote_changed and poll.vote_removed with the generated models. An event without a cid is
    still rejected: the spec makes it optional because feeds shares these events, but chat always sends it.
  • A cast or changed vote that is an answer still maps to AnswerCastedEvent.
  • Read adapters collect the events' custom data. Delete the hand-written poll event DTOs.
  • Exclude generated code from detekt's MagicNumber, as LongMethod already does.

Testing

GeneratedPollEventParsingTest covers each event on the WebSocket and /sync paths, answers, a missing
cid and a nanosecond created_at; ExactDateParsingTest pins the date parsing.

On a device: voted, changed the vote, answered, removed the vote, renamed, closed and deleted a poll.
Every event arrived with the right cid, message, poll and vote, and a rawCreatedAt keeping the server's
precision.

🤖 Generated with Claude Code

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

github-actions Bot commented Sep 28, 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 28, 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 13.09 MB 13.09 MB 0.00 MB 🟢

@gpunto
gpunto marked this pull request as ready for review September 29, 2026 07:39
@gpunto
gpunto requested a review from a team as a code owner September 29, 2026 07:39
@coderabbitai

coderabbitai Bot commented Sep 29, 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: 4177b0ce-69b7-4c44-ad62-512e532262b1

📥 Commits

Reviewing files that changed from the base of the PR and between 6cca78b and 5dea782.

📒 Files selected for processing (20)
  • config/detekt/detekt.yml
  • 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/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/EventAdapter.kt
  • stream-chat-android-client/src/main/java/io/getstream/chat/android/client/parser2/adapters/PollEventAdapters.kt
  • stream-chat-android-client/src/main/java/io/getstream/chat/android/network/infrastructure/ExactDate.kt
  • stream-chat-android-client/src/main/java/io/getstream/chat/android/network/infrastructure/ExactDateAdapter.kt
  • stream-chat-android-client/src/main/java/io/getstream/chat/android/network/models/PollClosedEvent.kt
  • stream-chat-android-client/src/main/java/io/getstream/chat/android/network/models/PollDeletedEvent.kt
  • stream-chat-android-client/src/main/java/io/getstream/chat/android/network/models/PollUpdatedEvent.kt
  • stream-chat-android-client/src/main/java/io/getstream/chat/android/network/models/PollVoteCastedEvent.kt
  • stream-chat-android-client/src/main/java/io/getstream/chat/android/network/models/PollVoteChangedEvent.kt
  • stream-chat-android-client/src/main/java/io/getstream/chat/android/network/models/PollVoteRemovedEvent.kt
  • stream-chat-android-client/src/main/java/io/getstream/chat/android/network/models/WSClientEvent.kt
  • stream-chat-android-client/src/main/java/io/getstream/chat/android/network/models/WSEvent.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/parser2/ExactDateParsingTest.kt
  • stream-chat-android-client/src/test/java/io/getstream/chat/android/client/parser2/GeneratedPollEventParsingTest.kt

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


Walkthrough

The client now parses poll lifecycle and vote events as WebSocket event models, preserves their timestamp strings through exact-date handling, and maps the events to domain types. The parser and mapping tests now cover the generated event flow.

Changes

Poll Event Flow

Layer / File(s) Summary
Event models and exact dates
stream-chat-android-client/src/main/java/io/getstream/chat/android/network/infrastructure/*, stream-chat-android-client/src/main/java/io/getstream/chat/android/network/models/*, stream-chat-android-client/src/test/java/io/getstream/chat/android/client/parser2/ExactDateParsingTest.kt, config/detekt/detekt.yml
Added WebSocket poll event models and exact-date support. Exact-date tests cover fractional timestamp inputs.
Poll event parser wiring
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/*, stream-chat-android-client/src/main/java/io/getstream/chat/android/client/api2/model/dto/EventDtos.kt
Registered poll event adapters and added parsing through WebSocket event models. Parsed models are wrapped in GeneratedEventDto; parsing rejects events with a missing cid.
Domain event mapping and validation
stream-chat-android-client/src/main/java/io/getstream/chat/android/client/api2/mapping/EventMapping.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/EventChatJsonProvider.kt, stream-chat-android-client/src/test/java/io/getstream/chat/android/client/parser2/GeneratedPollEventParsingTest.kt
Mapped generated poll and vote events to domain events. Answer votes map to answer-cast events; current-user votes are added to or replaced in the poll. Tests cover parsing, mapping, identifiers, and timestamps.

Priority: ➖ Normal

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

Change: Refactor

Sequence Diagram(s)

sequenceDiagram
  participant MoshiChatParser
  participant EventAdapter
  participant PollVoteCastedEventAdapter
  participant GeneratedEventDto
  participant EventMapping
  MoshiChatParser->>EventAdapter: Register event adapters
  EventAdapter->>PollVoteCastedEventAdapter: Deserialize poll.vote_casted JSON
  PollVoteCastedEventAdapter->>EventAdapter: Return parsed vote event
  EventAdapter->>GeneratedEventDto: Wrap the WSEvent
  EventAdapter->>EventMapping: Dispatch the generated event DTO
Loading

Suggested reviewers: andremion, velikovpetar

Merge Risk: ⚪ Minimal · up to 5dea7

Poll events now parse through generated models and keep their server timestamps. I found no concrete merge-blocking problem. Behavior on Android versions below API 26 was not checked on a device, so it is worth confirming there.

Security Architecture Review

Security architecture risk: 🔵 Low · up to 5dea7

The new parsing path preserves the reviewed channel and vote-ownership checks, and no introduced security weakness was established. The contract change still merits review because it affects both live and synchronized poll events.

Retained concerns
No architecture-level concerns identified.

Security review details

Security Blast Radius

  • inferred — The affected exposure is client-side interpretation of received poll and vote events, including the poll snapshot and current-user vote view. No infrastructure or privilege change is established by the reviewed change.

Trust Boundaries and Controls

  • observed — A received generated event must supply cid, and its vote must identify the current user before the mapped poll gains an own-vote entry. Comparison with the former DTO path found these controls preserved.
🚥 Pre-merge checks | ✅ 4 | ❌ 1

❌ Failed checks (1 warning)

Check name Status Explanation Resolution
Docstring Coverage ⚠️ Warning Docstring coverage is 20.63% which is insufficient. The required threshold is 80.00%. Docstring coverage is scoped to functions touched by this diff. Analyzed 63 functions across 19 files. (1 skipped:… 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.
Description check ✅ Passed The description clearly states the goal, implementation, testing coverage, device validation, and related issue. UI, checklist, reviewer checklist, and GIF sections are not completed, but these omissi…
Title check ✅ Passed The title clearly and concisely describes the primary change: migrating poll events to generated poll event models.
Full details: Docstring Coverage

Explanation

Docstring coverage is 20.63% which is insufficient. The required threshold is 80.00%. Docstring coverage is scoped to functions touched by this diff. Analyzed 63 functions across 19 files. (1 skipped: 1 unsupported.)

  • Fix all pre-merge checks with AI
✨ Finishing Touches 💡 2
📝 Generate docstrings 💡
  • Commit to this branch
  • Create a new PR
🛠️ Fix failing CI checks 💡
  • 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 dates at dawn,
Poll votes hop through, then travel on.
A closed poll rests beneath the moon,
Changed answers find their mapping soon.
The burrow hums: each event is known!

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. Two small questions inline, both optional.

@sonarqubecloud

Copy link
Copy Markdown

Quality Gate Failed Quality Gate failed

Failed conditions
77.9% Coverage on New Code (required ≥ 80%)

See analysis details on SonarQube Cloud

@gpunto
gpunto added this pull request to the merge queue Sep 29, 2026
Merged via the queue into develop with commit 8bd689c Sep 29, 2026
19 of 20 checks passed
@gpunto
gpunto deleted the migrate/poll-events branch September 29, 2026 11:46
@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

🚀 Available in v7.13.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