Skip to content

Migrate queryReactions request body to the generated QueryReactionsRequest model#6564

Merged
gpunto merged 2 commits into
developfrom
migrate/query-reactions
Jul 10, 2026
Merged

Migrate queryReactions request body to the generated QueryReactionsRequest model#6564
gpunto merged 2 commits into
developfrom
migrate/query-reactions

Conversation

@gpunto

@gpunto gpunto commented Jul 9, 2026

Copy link
Copy Markdown
Contributor

Goal

Migrate the queryReactions request body (POST /messages/{id}/reactions) to the generated QueryReactionsRequest network model. Introduces the shared SortParamRequest model + a QuerySorter -> List<SortParamRequest> helper that the remaining query-payload migrations will reuse. Part of the incremental OpenAPI model migration.

Part of AND-1291

Implementation

  • Add generated internal QueryReactionsRequest + SortParamRequest in network.models (patch-free). Delete the hand-written api2.model.requests.QueryReactionsRequest. Real names, no alias.
  • The generated sort field is now List<SortParamRequest> (was List<Map<String, Any>>). Add a top-level internal fun QuerySorter<*>.toSortParams(): List<SortParamRequest> (ported from the reference) mapping each sort entry to SortParamRequest(field, direction), and change the queryReactions call site from sort = sort?.toDto() to sort = sort?.toSortParams(). filter?.toMap() (Map<String, Any>) fits the generated Map<String, Any?> field. No wire-shape change.

Testing

  • spotlessApply, apiCheck (no API drift), detekt, and the full client testDebugUnitTest suite pass.
  • Verified on device: queryReactions with a created_at desc sort serializes on the wire as {"limit":10,"sort":[{"direction":-1,"field":"created_at"}]} and returns 201. The sort array confirms the new SortParamRequest serialization via toSortParams() (the migration's changed surface; the response type is unchanged by this slice).

Summary by CodeRabbit

  • New Features

    • Improved reaction query handling, including better support for pagination, sorting, and filtering in reaction-related requests.
    • Updated reaction request serialization to match the latest network format.
  • Bug Fixes

    • Fixed inconsistencies in how reaction query sort values are sent, helping requests work more reliably.
  • Tests

    • Added coverage for reaction request JSON serialization and deserialization, including default and fully populated cases.

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

github-actions Bot commented Jul 9, 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 Jul 9, 2026

Copy link
Copy Markdown
Contributor

SDK Size Comparison 📏

SDK Before After Difference Status
stream-chat-android-client 5.94 MB 5.94 MB 0.00 MB 🟢
stream-chat-android-ui-components 11.20 MB 11.21 MB 0.01 MB 🟢
stream-chat-android-compose 12.68 MB 12.68 MB 0.00 MB 🟢

@gpunto gpunto marked this pull request as ready for review July 9, 2026 15:35
@gpunto gpunto requested a review from a team as a code owner July 9, 2026 15:35
@gpunto gpunto enabled auto-merge (squash) July 9, 2026 15:59
@coderabbitai

coderabbitai Bot commented Jul 9, 2026

Copy link
Copy Markdown

Review Change Stack

Walkthrough

QueryReactionsRequest and SortParamRequest models are relocated/redefined under io.getstream.chat.android.network.models. MoshiChatApi now converts sort via a new toSortParams() extension instead of toDto() when building queryReactions. Imports in MessageApi and tests are updated accordingly, and new parser adapter tests with test data are added.

Changes

QueryReactions Sort Model Migration

Layer / File(s) Summary
New network models
.../network/models/QueryReactionsRequest.kt, .../network/models/SortParamRequest.kt
Adds internal Moshi-serializable QueryReactionsRequest and redefines SortParamRequest with nullable direction/field/type properties under the network.models package.
Sort serialization helper and request builder
.../client/api2/MoshiChatApi.kt
Adds QuerySorter<*>.toSortParams() extension mapping sorter keys to SortParamRequest, updates imports, and switches queryReactions to use toSortParams() instead of toDto().
Endpoint and test wiring
.../client/api2/endpoint/MessageApi.kt, .../client/api2/MoshiChatApiTest.kt, .../client/parser2/QueryReactionsRequestAdapterTest.kt, .../client/parser2/testdata/QueryReactionsRequestTestData.kt
Updates MessageApi and test imports to the new QueryReactionsRequest type, adjusts expected test payloads to use toSortParams(), and adds new serialization/deserialization parser tests with fixture data.

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

Sequence Diagram(s)

sequenceDiagram
  participant MoshiChatApi
  participant QuerySorter
  participant QueryReactionsRequest

  MoshiChatApi->>QuerySorter: toSortParams()
  QuerySorter-->>MoshiChatApi: List<SortParamRequest>
  MoshiChatApi->>QueryReactionsRequest: build with sort params
Loading

Suggested reviewers: andremion

Poem

A hop, a skip, a model renamed,
Sort params tucked where network's framed,
toSortParams() replaces toDto's trail,
Tests confirm the JSON doesn't fail,
This bunny thumps approval — deploy the tale! 🐰✨

🚥 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%. 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 states the main change: migrating queryReactions to the generated QueryReactionsRequest model.
Description check ✅ Passed Goal, implementation, and testing are filled in with concrete details; only non-critical UI/checklist/GIF sections are omitted.
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.
✨ Finishing Touches
📝 Generate docstrings
  • Create stacked PR
  • Commit on current branch
🧪 Generate unit tests (beta)
  • Create PR with unit tests
  • Commit unit tests in branch migrate/query-reactions

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.

@coderabbitai coderabbitai Bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

🧹 Nitpick comments (1)
stream-chat-android-client/src/test/java/io/getstream/chat/android/client/api2/MoshiChatApiTest.kt (1)

452-465: 🎯 Functional Correctness | 🔵 Trivial | ⚡ Quick win

Test doesn't exercise the new toSortParams() field/direction mapping.

sort = QuerySortByField<Reaction>() is empty, so toSortParams()'s extraction/casting logic (the new code this PR introduces) always maps to an empty list here — the test can't catch a regression in that mapping. Other tests in this class (e.g. testQueryBannedUsers) use a populated sorter to actually exercise the mapping.

♻️ Suggested fix: use a populated sorter
-        val sort = QuerySortByField<Reaction>()
+        val sort = QuerySortByField.descByName<Reaction>("created_at")
🤖 Prompt for AI Agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.

In
`@stream-chat-android-client/src/test/java/io/getstream/chat/android/client/api2/MoshiChatApiTest.kt`
around lines 452 - 465, The test in MoshiChatApiTest.queryReactions uses an
empty QuerySortByField, so it never exercises the new toSortParams()
field/direction mapping. Update this test to build a populated
QuerySortByField<Reaction> with at least one field and sort direction, then keep
the expected QueryReactionsRequest assertion using sort.toSortParams() so the
mapping logic is actually verified. Use the existing queryReactions and
QuerySortByField helpers in this test class as the reference points.
🤖 Prompt for all review comments with AI agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.

Nitpick comments:
In
`@stream-chat-android-client/src/test/java/io/getstream/chat/android/client/api2/MoshiChatApiTest.kt`:
- Around line 452-465: The test in MoshiChatApiTest.queryReactions uses an empty
QuerySortByField, so it never exercises the new toSortParams() field/direction
mapping. Update this test to build a populated QuerySortByField<Reaction> with
at least one field and sort direction, then keep the expected
QueryReactionsRequest assertion using sort.toSortParams() so the mapping logic
is actually verified. Use the existing queryReactions and QuerySortByField
helpers in this test class as the reference points.

ℹ️ Review info
⚙️ Run configuration

Configuration used: Repository UI

Review profile: CHILL

Plan: Pro

Run ID: d63a43fd-b824-4c97-9227-9c6d6d7f4122

📥 Commits

Reviewing files that changed from the base of the PR and between e26038e and 08c6a33.

📒 Files selected for processing (7)
  • stream-chat-android-client/src/main/java/io/getstream/chat/android/client/api2/MoshiChatApi.kt
  • stream-chat-android-client/src/main/java/io/getstream/chat/android/client/api2/endpoint/MessageApi.kt
  • stream-chat-android-client/src/main/java/io/getstream/chat/android/network/models/QueryReactionsRequest.kt
  • stream-chat-android-client/src/main/java/io/getstream/chat/android/network/models/SortParamRequest.kt
  • stream-chat-android-client/src/test/java/io/getstream/chat/android/client/api2/MoshiChatApiTest.kt
  • stream-chat-android-client/src/test/java/io/getstream/chat/android/client/parser2/QueryReactionsRequestAdapterTest.kt
  • stream-chat-android-client/src/test/java/io/getstream/chat/android/client/parser2/testdata/QueryReactionsRequestTestData.kt

@sonarqubecloud

sonarqubecloud Bot commented Jul 9, 2026

Copy link
Copy Markdown

Quality Gate Failed Quality Gate failed

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

See analysis details on SonarQube Cloud

@gpunto gpunto merged commit 3e3769b into develop Jul 10, 2026
19 of 20 checks passed
@gpunto gpunto deleted the migrate/query-reactions branch July 10, 2026 08:30
@stream-public-bot stream-public-bot added the released Included in a release label Jul 13, 2026
@stream-public-bot

Copy link
Copy Markdown
Contributor

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