refactor(shared): unify gateway event payloads across server and bot-sdk #106
No reviewers
Labels
No labels
area:api
area:core
area:docs
area:infra
area:ux
dependencies
documentation
duplicate
good first issue
help wanted
invalid
question
rust
status:complete
status:partial
status:planned
type:bug
type:design
type:feature
type:infra
type:refactor
type:refactor
type:research
type:ux
wontfix
No milestone
No project
No assignees
1 participant
Notifications
Due date
No due date set.
Dependencies
No dependencies set.
Reference
icub3d/decentcom!106
Loading…
Add table
Add a link
Reference in a new issue
No description provided.
Delete branch "feature/82-gateway-event-payloads"
Deleting a branch is permanent. Although the deleted branch may continue to exist for a short time before it actually gets removed, it CANNOT be undone in most cases. Continue?
Completes the final checkbox of #82 (gateway event payloads), following #105 which did the REST wire types and SDK client commands.
Problem
The server broadcaster and the bot-sdk each defined their own gateway event payload types, and they had drifted. serde only ignores extra fields, not missing required ones, so this wasn't cosmetic:
MessageEvent/ChannelEvent/RoleEvent/MemberEventwere trimmed subsets — a bot'son_messagenever sawattachments/reactions/thread/deleted.MEMBER_LEAVE({user_id, pubkey, left_at}),MEMBER_BAN({pubkey, banned_by, reason, banned_at}— nouser_id),MEMBER_UPDATE(nois_bot/joined_at), andTHREAD_MESSAGE_CREATE({thread_id, message}vs. the SDK decodingThreadEventData) did not match what the server sends, so those events failed to decode in every bot.Fix — one definition per payload
shared::gatewaypayload structs:ThreadMessageData,MessageDeleteData,DeletedId(shared by channel + role delete),MemberLeaveData,MemberKickData,MemberBanData,MemberUpdateData. Resource-carrying events reuse theshared::resttypes (Message,Channel,Role,Member).serde_json::json!literals and local one-off structs, so the broadcast shape is now compile-time checked against the shared definition.Eventenum, handler-type aliases,Context::reply, and the example bots (auditbot/modbot/welcomebot) all consume the shared types. bot-sdk keeps zero local event copies. Member join/leave/kick/ban/update now carry distinct, correct payload types (previously three of them shared one trimmedMemberEvent).Wire compatibility
The server's outgoing JSON is byte-identical to before — I checked each broadcast against the React/Tauri client's actual field reads (
client/src/stores/members.ts,threadStore.ts). This PR only fixes the bot-sdk decode side. A newsharedtest locks the wire field names of the small event payloads so they can't silently drift again.Also removes a stray unused
serde::Serializeimport inprofiles/handlers.rsthat surfaced from the #104 + #105 merge interaction (would failclippy -D warningson current main).Verification
cargo build --workspace— cleancargo clippy --workspace --all-targets -- -D warnings— cleancargo test --workspace— all pass (server 131, shared 10, SDK 8, bot-sdk 10 incl. rewritten member-event decode tests, example bots build)Closes #82
🤖 Generated with Claude Code