Repository navigation
refactor(llc)!: route user updates through the generated client - #3052
Draft
VelikovPetar wants to merge 4 commits into
Draft
VelikovPetar wants to merge 4 commits into
VelikovPetar wants to merge 4 commits into
Conversation
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Contributor
|
Important Draft PR not reviewedDraft PRs are not automatically reviewed by default.
To automatically review draft PRs, update your CodeRabbit configuration: reviews:
auto_review:
drafts: true
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. Comment |
3 tasks done
…refactor/flu-953_user_updates_openapi_migration
…refactor/flu-953_user_updates_openapi_migration
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
This branch has not been deployed
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Submit a pull request
Linear: FLU-953
Github Issue: -
CLA
Description of the pull request
Moves creating, updating and partially updating users onto the OpenAPI-generated client, as plan group 20 (User Updates), split out of group 09. Stacked on #3050.
StreamChatClient.updateUserandupdateUsersreturnResult<UpdateUsersResponse>instead of throwing.partialUpdateUserandpartialUpdateUsersare renamedupdateUserPartialandupdateUsersPartial, and returnResult<UpdateUsersResponse>;PartialUpdateUserRequestis renamedUpdateUserPartialRequest(freezed, notoJson).UpdateUsersResponsemoves tomodels/response/as a freezed class with a non-nullduration.User(andOwnUser) gaindeactivatedAt,deletedAtandshadowBannedas getters overextraData; every generated user mapper fills the ones its response carries.updateUsersends only the user's name, image, language, visibility and custom data.UsersRepositorygains the two operations;user_mapper.dartgainsFullUserResponseMapper,UpdateUsersResponseMapperandUpdateUserPartialRequestMapper. The two methods are removed fromStreamChatApi.user.DefaultApi.updateUsers(POST /api/v2/users)StreamChatClient.updateUser,updateUsersDefaultApi.updateUsersPartial(PATCH /api/v2/users)StreamChatClient.updateUserPartial,updateUsersPartialUpdateUsersResponseUpdateUsersResponse(ours, freezed)FullUserResponseUserUpdateUserPartialRequestUpdateUserPartialRequest(ours, freezed; wasPartialUpdateUserRequest)UserRequestUserby the existingtoRequest()Why
The migration moves every endpoint onto the generated client, which returns a
Resultfor every call. Users decoded from the generated client were also losingdeactivatedAt,deletedAtandshadowBanned, which v1 kept raw inextraData; the getters restore them.Notes for reviewers
Important
FullUserResponsemaps toUser; there is no public full-user type. Please weigh in. The generated response answers aFullUserResponseper user: the profile plus the fields only that user can see (devices, mutes, channel mutes, privacy settings, unread counts, blocked user ids, hidden channels, token revocation time).UpdateUsersResponsekeeps v10'sMap<String, User>and maps each entry to aUser, dropping that private part. A client-side token can only update its own user (the backend refuses anyone else, even for a client-side admin) and blanks the private part for other users, so aFullUsertype would hold empty fields for others and duplicateOwnUserfor the caller, whose private fields are oncurrentUseranyway.queryUsers(group 09) answers the same type and reuses this mapper. The trade-off: v10 callers could read those fields raw fromextraData; now they can't. Mapping the caller's own entry to anOwnUserstays an additive option onceMute,ChannelMuteandPrivacySettingshave response mappers.Other decision points:
Userfield promotion, theMemberpattern: constructor arguments stored inextraData, read back through typed getters, with no persistence change. Whether to turn them into real fields is left to group 09, alongside group 11'sChannelModelandMemberpromotions.revokeTokensIssuedBeforeis deliberately left out.updateChannelPartialandupdateMemberPartial. Hard renames, no deprecated aliases.updateUserno longer sendsrole,teamsorteamsRole. A client-side token never stored them, and a different role was refused with a 403; such a call now succeeds without changing the role.user.updatedevent keepscurrentUserin sync.Backend:
POST/PATCH /usersand/api/v2/usersareUpdateUsersandUpdateUsersPartialfrom the common routes, mounted twice; only the JSON encoding differs. Not feature-flagged, in beta or deprecated.online,banned, timestamps, devices, unread counts, push preferences) as custom data on every upsert, as a v2 read shows. v2 stores only thecustomit is given, andtoRequest()now also leaves out the own-user keys anOwnUsercarries from the connection.language: nullandinvisible: nullbehave like v10's omitted keys.ConnectUserDetailsstill flattensextraDatainto the WebSocket connect payload; it gets stripped when the WebSocket moves to v2.Testing
melos run analyzeclean;stream_chatsuite green (1,917 tests);stream_chat_persistenceandstream_chat_flutter_coregreen.generate_plan.py --checkreports 0 problems.client_update_users_test.dartandclient_update_users_partial_test.dart:FullUserResponsemapped to the envelope;client_connect_guest_user_test.dartanduser_test.dartare extended for the promoted fields.languagesurvives every write;nulls work;Screenshots / Videos
Not applicable: no visible UI change.
🤖 Generated with Claude Code