Repository navigation
Migrate the user on user, read and delivery events to the generated user field models - #6724
Conversation
SDK Size Comparison 📏
|
|
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 configurationConfiguration used: Repository UI Review profile: CHILL Plan: Advanced Run ID: 📒 Files selected for processing (12)
Included review availability: Your plan provides up to 4 included reviews per hour; 1 remains after this review. WalkthroughEvent DTOs now use common user response fields for most user events and privacy fields for ChangesEvent user response mapping
Estimated code review effort: 3 (Moderate) | ~25 minutes Sequence Diagram(s)sequenceDiagram
participant EventPayload
participant MoshiChatParser
participant EventUserAdapter
participant EventDto
participant DomainMapping
EventPayload->>MoshiChatParser: Parse event JSON
MoshiChatParser->>EventUserAdapter: Deserialize event user
EventUserAdapter-->>EventDto: Provide common or privacy response
EventDto->>DomainMapping: Convert response user
DomainMapping-->>EventDto: Return domain User
Suggested reviewers: Merge Risk: ⚪ Minimal · up to User, read, delivery, ban, and watching events now parse their embedded user with shapes that match the backend's event user fields. Device data moves into the typed field, and the remaining custom fields are preserved. No concrete defect was identified, so the change appears ready to merge after normal checks. 🚥 Pre-merge checks | ✅ 4 | ❌ 1❌ Failed checks (1 warning)
✅ Passed checks (4 passed)
✨ Finishing Touches 💡 1📝 Generate docstrings 💡
🧪 Generate unit tests (beta)
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. A rabbit checks the fields in rows, Comment |
andremion
left a comment
There was a problem hiding this comment.
Looks good. One optional nit inline.
…ponseCommonFields
b7da720 to
bab6104
Compare
|




Goal
Parse the user carried by the user, read and delivery events with the generated models the backend
serializes them from.
Part of AND-1291
Implementation
useronuser.updatedatUserResponsePrivacyFields, and onuser.presence.changed,user.deleted,user.watching.start/stop, the channel and global ban/unban events,message.delivered,notification.mark_read(per channel and mark-all),notification.mark_unreadanduser.messages.deletedatUserResponseCommonFields. These match the structs the backend embeds in eachevent. Vendors both models.
User, and collecting adapters so the flattened custom fields land incustom.deleted_atandrevoke_tokens_issued_beforeinextraDataas well. Both models declare them andthe domain has no property for either.
devicesout of the custom data into the typeddevices, and drop it fromextraData.Notes
Neither model declares
devices, but event users can carry a device list as custom data, in the requestshape. The previous DTO declared the key, so it always ended up in
User.devices. Without promoting it, itwould surface in
extraDataand, becauseuser.updatedmerges into the current user, in the current user'sextraDatatoo.languagegoes from nullable to required. It is a plain non-pointer tag on the shared user fields, so it isalways sent. The event test fixtures now use the shapes these events actually carry, without the own-user
state (devices, mutes, unread counts) the previous shared fixture had.
On the read and delivery events the backend embeds the user as optional (
json:"user,omitempty"), whilethe DTOs keep it required. In practice the reader is always set: the mark-all-read constructor dereferences
it directly. Keeping it required matches the previous behavior.
The mock server does not emit the user events; it builds
notification.mark_unreadfrom a recorded userthat has every required field.
Testing
Mutation sweep over both mappers: zero survivors. A parsing test feeds whole event payloads through the
parser to cover the adapters, the kept keys and the devices promotion end to end.
Device-probed
user.updated,user.watching.start,notification.mark_unread,notification.mark_readandmark-all-read with a custom field set on the user:
language, the custom field and 16 devices came throughthe typed fields, with no
deviceskey in the event user's or the current user'sextraData. Presence, ban,delete,
message.deliveredanduser.messages.deletedare not reachable from a single client and arecovered by the parsing tests.
Summary by CodeRabbit