Skip to content

Migrate the privacy settings to the generated model in both directions - #6699

Open
gpunto wants to merge 1 commit into
developfrom
migrate/privacy-settings
Open

Migrate the privacy settings to the generated model in both directions#6699
gpunto wants to merge 1 commit into
developfrom
migrate/privacy-settings

Conversation

@gpunto

@gpunto gpunto commented Sep 14, 2026

Copy link
Copy Markdown
Contributor

Goal

Parse and serialize the user's privacy settings with the generated PrivacySettingsResponse, retiring the
four hand-written privacy DTOs.

Part of AND-1291

Implementation

  • Point privacy_settings on both UpstreamUserDto and DownstreamUserDto at the generated model and
    delete PrivacySettings.kt, which held all four DTOs.
  • Collapse the four toDto mappers into one and drop the four toDomain mappers, since
    PrivacySettingsResponse.toDomain() already existed.

Notes

Both directions move in one slice, which the earlier ones could not do. The spec declares
UserRequest.privacy_settings and FullUserResponse.privacy_settings as the same
PrivacySettingsResponse, so no hand-written DTO has to stay behind to serve toDto().

Field parity is exact: three nullable settings, each wrapping a required enabled. Nothing changes
requiredness in either direction.

Devices are the obvious neighbour on DownstreamUserDto and are deliberately left alone.
DeviceResponse requires created_at and user_id, which DeviceDto does not declare, and devices
arrive lean on the WebSocket, so that swap needs its own slice and its own probe.

Testing

  • Mutation sweep over both mappers: zero survivors, three fields each.
  • The upstream wire format is provably unchanged. The fixture diff touches only Kotlin object
    constructions, not one line of JSON, so UpstreamUserDtoAdapterTest serializing that object to the same
    expected JSON is the proof.
  • Device-probed both directions: updateUser put all three settings on the wire through the new toDto,
    and the response plus a fresh queryUsers read them back, with the three values deliberately differing
    so a mapper crossing two of them would fail. A second run over partialUpdateUser covered the PATCH
    endpoint as well.

Summary by CodeRabbit

  • Bug Fixes

    • Improved privacy-settings handling by consistently using the response format across user data, mapping, and parsing.
    • Preserved support for typing indicators, read receipts, and delivery receipts, including cases where delivery receipts are unavailable.
  • Tests

    • Updated privacy-settings mapping, parsing, and user-data coverage to validate the current response format.
    • Retained error-handling and JSON parsing coverage for privacy settings.

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

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 14, 2026

Copy link
Copy Markdown
Contributor

SDK Size Comparison 📏

SDK Before After Difference Status
stream-chat-android-client 6.09 MB 6.08 MB -0.00 MB 🚀
stream-chat-android-ui-components 11.39 MB 11.39 MB 0.00 MB 🟢
stream-chat-android-compose 13.07 MB 13.07 MB 0.00 MB 🟢

@gpunto
gpunto marked this pull request as ready for review September 14, 2026 09:43
@gpunto
gpunto requested a review from a team as a code owner September 14, 2026 09:43
@coderabbitai

coderabbitai Bot commented Sep 14, 2026

Copy link
Copy Markdown

Review Change StackReview Change Stack

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: db992a56-16fd-4038-a1ff-2b2239668371

📥 Commits

Reviewing files that changed from the base of the PR and between 7c12807 and 71ac0e6.

📒 Files selected for processing (9)
  • 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/mapping/DtoMapping.kt
  • stream-chat-android-client/src/main/java/io/getstream/chat/android/client/api2/model/dto/PrivacySettings.kt
  • stream-chat-android-client/src/main/java/io/getstream/chat/android/client/api2/model/dto/UserDtos.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/DtoMappingTest.kt
  • stream-chat-android-client/src/test/java/io/getstream/chat/android/client/parser2/PrivacySettingsParsingTest.kt
  • stream-chat-android-client/src/test/java/io/getstream/chat/android/client/parser2/testdata/UserDtoTestData.kt
💤 Files with no reviewable changes (3)
  • stream-chat-android-client/src/main/java/io/getstream/chat/android/client/api2/model/dto/PrivacySettings.kt
  • stream-chat-android-client/src/test/java/io/getstream/chat/android/client/api2/mapping/DomainMappingTest.kt
  • stream-chat-android-client/src/main/java/io/getstream/chat/android/client/api2/mapping/DomainMapping.kt

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


Walkthrough

Changes

Privacy settings model migration

Layer / File(s) Summary
Response model contracts
stream-chat-android-client/src/main/java/io/getstream/chat/android/client/api2/model/dto/UserDtos.kt, stream-chat-android-client/src/main/java/io/getstream/chat/android/client/api2/model/dto/PrivacySettings.kt, stream-chat-android-client/src/test/java/io/getstream/chat/android/client/Mother.kt
User DTOs now use PrivacySettingsResponse. The legacy privacy settings DTO file and test builders are removed.
Response model mapping
stream-chat-android-client/src/main/java/io/getstream/chat/android/client/api2/mapping/DtoMapping.kt, stream-chat-android-client/src/main/java/io/getstream/chat/android/client/api2/mapping/DomainMapping.kt
PrivacySettings.toDto() now creates nested response models. Legacy privacy settings DTO mappings and imports are removed.
Mapping and parsing validation
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/parser2/*
Tests and fixtures now use response models. They validate populated fields, missing optional values, and missing enabled errors.

Priority: ⬇️ Low

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

Change: Refactor

Suggested reviewers: velikovpetar

Merge Risk: ⚪ Minimal · up to 71ac0

No actionable merge-blocking risk is identified in the privacy-settings model migration.

🚥 Pre-merge checks | ✅ 4 | ❌ 1

❌ Failed checks (1 warning)

Check name Status Explanation Resolution
Docstring Coverage ⚠️ Warning Docstring coverage is 33.33% which is insufficient. The required threshold is 80.00%. Docstring coverage is scoped to functions touched by this diff. Analyzed 12 functions across 6 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 and concisely describes the main change: migrating privacy settings to the generated model in both directions.
Description check ✅ Passed The description includes the goal, implementation details, scope notes, issue link, and detailed testing evidence. It omits the UI, checklist, reviewer checklist, and GIF sections, but these are not r…
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 💡
  • Create stacked PR
  • Commit on current branch
🧪 Generate unit tests (beta)
  • Create PR with unit tests
  • Commit unit tests in branch migrate/privacy-settings

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

I’m a rabbit with a tidy chart
Response models now do their part
Old DTOs hop away
Tests guard the path each day
Privacy fields make a fresh start

Comment @coderabbitai help to get the list of available commands.

@gpunto
gpunto force-pushed the migrate/privacy-settings branch from 71ac0e6 to f40eadf Compare September 14, 2026 10:58
@sonarqubecloud

Copy link
Copy Markdown

@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.

*/
internal fun DeliveryReceipts.toDto(): DeliveryReceiptsDto = DeliveryReceiptsDto(
enabled = enabled,
internal fun PrivacySettings.toDto(): PrivacySettingsResponse = PrivacySettingsResponse(

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 now identical to the private toResponse() below (line 287), same receiver, same return type, same body. They only differed before because toDto() returned PrivacySettingsDto. Any reason not to have toUserRequest() call toDto() and drop toResponse()? Happy to be told otherwise if you want the request path to keep its own name.

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