refactor(server): add ChannelMember extractor for channel-scoped routes (#83) #110
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!110
Loading…
Add table
Add a link
Reference in a new issue
No description provided.
Delete branch "feature/83-channel-member"
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?
Finishes #83. The first checklist item — one
crate::error::ApiError+ crate-wideApiResult— landed in #104; this PR delivers the second: theChannelMemberextractor.Closes #83.
What it does
ChannelMember(server/src/permissions.rs) is aFromRequestPartsextractor for routes under/channels/:channel_id/…. It runs the prologue those handlers repeated by hand: authentication + server membership (same checks asMemberUser), resolving thechannel_idpath parameter, channel existence (404 channel not found), and channel-scopedeffective_permissions— computed once. The oldUserPermissions+effective_permissionspairing computed base permissions twice per request; converted handlers now do it once.Converted handlers (11)
messages: create / list / get / update / deletereactions: put_reaction / delete_own / delete_user / list_reactorsattachments: upload_attachmentthreads: create_threadEach loses its
ensure_channel_exists+effective_permissionsprologue and checks bits viamember.has(…).channels::update_channel/delete_channelkeep the explicit call — there the channel is the target (step 6), not the parent.Also
permissions.rshad its own privatePermissionRejection/ErrorBody— exactly the duplication this issue is about. Both extractors now reject withcrate::error::ApiError, and they share anauthed_member()prologue.reactions::tests::missing_channel_404s_even_when_reactions_disabled).No wire-format changes; client and SDKs untouched.
Verification
cargo test --workspace— 210 passed (all existing router-level handler tests exercise the converted routes; 1 new)cargo clippy --workspace --all-targets -- -D warnings,cargo fmt --check— clean🤖 Generated with Claude Code