Server admin 5: fluxer-api channels, members, bans, member search, invites (#671) #718

Closed
charles wants to merge 0 commits from serveradmin-5-api-channels-members-bans into serveradmin
Owner

What this builds

fluxer-api endpoints for channel administration and moderation (plan Task 5, spec §3.5–3.8, §5):

  • channels_admin.rs: update_channel(channel, &ChannelUpdateRequest) -> Channel (PATCH /channels/{id}), update_channel_positions(guild, &[ChannelPosition]) (PATCH /guilds/{id}/channels, 204), follower_stats(channel) -> FollowerStats.
  • moderation.rs: update_member(guild, user, &MemberUpdateRequest) -> GuildMember, update_own_member(guild, &MemberUpdateRequest) -> GuildMember (.../members/@me), add_member_role / remove_member_role (PUT/DELETE .../members/{u}/roles/{r}, 204), kick_member (DELETE .../members/{u}, 204), ban_member(guild, user, &BanCreateRequest) (PUT .../bans/{u}, 204), list_bans(guild) -> Vec<GuildBan> (lenient: an unreadable entry is dropped), unban_member (204), search_members(guild, &MemberSearchRequest) -> MemberSearchResponse (POST .../members-search).
  • invites.rs: list_guild_invites(guild) -> Vec<InviteMetadata> (GET /guilds/{id}/invites), delete_invite(code) (DELETE /invites/{code}, 204, code percent-encoded as one segment).
  • Guild-channel deletion reuses the existing delete_channel.
  • Retry policy as the rest of the crate: GETs retry once after a 429, writes and the search POST never.

Testing

  • crates/fluxer-api/tests/channels_admin.rs (7) and tests/moderation.rs (15), wiremock, against the proto fixtures (bodies matched with body_json against fixtures/rest/*.json): one per method for method/path/body/answer, plus own_member_goes_to_me, kick_and_unban_204, member_search_post_body, member_search_indexing, user_is_not_banned_error, timeout_too_long_error, missing-permissions cases.
  • New error fixtures fixtures/errors/{user_is_not_banned,timeout_cannot_exceed_365_days}.json, shaped like InputValidationError.fromCode at GuildModerationService.ts:263 and GuildMemberOperationsService.ts:603, messages from the en-GB error locale.
  • FLUXER_SCREENSHOT_TESTS=1 cargo xtask ci green locally. No display tests (FLUXER_DESKTOP_TESTS) apply.

Deviations / for the reviewer

  • crates/fluxer-api/src/error.rs (not in the task's Files list): USER_IS_NOT_BANNED and TIMEOUT_CANNOT_EXCEED_365_DAYS arrive nested in a 400 INVALID_FORM_BODY; they are now lifted to ApiError::Http.code with that entry's message, exactly like the existing entrance-sound codes (one extra || on the same predicate; the list lives in moderation.rs). Without it the runtime could not tell these refusals apart. Task 4 may touch error.rs too; any conflict should be mechanical.
  • update_own_member returns GuildMember (the plan gives no return type; the route answers GuildMemberResponse like the other member PATCH).
  • No Retry on search_members (a POST, as search_messages).

Stacked on: origin/serveradmin-2-proto-channel-admin, origin/serveradmin-3-proto-members-bans-invites (both already merged into serveradmin at base 7cd8bb1c).

Closes #671

🤖 Generated with Claude Code

https://claude.ai/code/session_0161qMQMsCyJhjYw4gqa6e4K

## What this builds `fluxer-api` endpoints for channel administration and moderation (plan Task 5, spec §3.5–3.8, §5): - `channels_admin.rs`: `update_channel(channel, &ChannelUpdateRequest) -> Channel` (`PATCH /channels/{id}`), `update_channel_positions(guild, &[ChannelPosition])` (`PATCH /guilds/{id}/channels`, 204), `follower_stats(channel) -> FollowerStats`. - `moderation.rs`: `update_member(guild, user, &MemberUpdateRequest) -> GuildMember`, `update_own_member(guild, &MemberUpdateRequest) -> GuildMember` (`.../members/@me`), `add_member_role` / `remove_member_role` (`PUT`/`DELETE .../members/{u}/roles/{r}`, 204), `kick_member` (`DELETE .../members/{u}`, 204), `ban_member(guild, user, &BanCreateRequest)` (`PUT .../bans/{u}`, 204), `list_bans(guild) -> Vec<GuildBan>` (lenient: an unreadable entry is dropped), `unban_member` (204), `search_members(guild, &MemberSearchRequest) -> MemberSearchResponse` (`POST .../members-search`). - `invites.rs`: `list_guild_invites(guild) -> Vec<InviteMetadata>` (`GET /guilds/{id}/invites`), `delete_invite(code)` (`DELETE /invites/{code}`, 204, code percent-encoded as one segment). - Guild-channel deletion reuses the existing `delete_channel`. - Retry policy as the rest of the crate: GETs retry once after a 429, writes and the search POST never. ## Testing - `crates/fluxer-api/tests/channels_admin.rs` (7) and `tests/moderation.rs` (15), wiremock, against the proto fixtures (bodies matched with `body_json` against `fixtures/rest/*.json`): one per method for method/path/body/answer, plus `own_member_goes_to_me`, `kick_and_unban_204`, `member_search_post_body`, `member_search_indexing`, `user_is_not_banned_error`, `timeout_too_long_error`, missing-permissions cases. - New error fixtures `fixtures/errors/{user_is_not_banned,timeout_cannot_exceed_365_days}.json`, shaped like `InputValidationError.fromCode` at `GuildModerationService.ts:263` and `GuildMemberOperationsService.ts:603`, messages from the en-GB error locale. - `FLUXER_SCREENSHOT_TESTS=1 cargo xtask ci` green locally. No display tests (FLUXER_DESKTOP_TESTS) apply. ## Deviations / for the reviewer - `crates/fluxer-api/src/error.rs` (not in the task's Files list): `USER_IS_NOT_BANNED` and `TIMEOUT_CANNOT_EXCEED_365_DAYS` arrive nested in a 400 `INVALID_FORM_BODY`; they are now lifted to `ApiError::Http.code` with that entry's message, exactly like the existing entrance-sound codes (one extra `||` on the same predicate; the list lives in `moderation.rs`). Without it the runtime could not tell these refusals apart. Task 4 may touch `error.rs` too; any conflict should be mechanical. - `update_own_member` returns `GuildMember` (the plan gives no return type; the route answers `GuildMemberResponse` like the other member PATCH). - No Retry on `search_members` (a POST, as `search_messages`). Stacked on: origin/serveradmin-2-proto-channel-admin, origin/serveradmin-3-proto-members-bans-invites (both already merged into serveradmin at base 7cd8bb1c). Closes #671 🤖 Generated with [Claude Code](https://claude.com/claude-code) https://claude.ai/code/session_0161qMQMsCyJhjYw4gqa6e4K
Wiremock tests for the channel, member, ban, member-search and guild
invite endpoints. Error fixtures shaped like the server:
user_is_not_banned.json from
fluxer_api/src/api/guild/services/GuildModerationService.ts:263
(InputValidationError.fromCode('user_id', USER_IS_NOT_BANNED)) and
timeout_cannot_exceed_365_days.json from
fluxer_api/src/api/guild/services/member/GuildMemberOperationsService.ts:603
(path communication_disabled_until); messages from
packages/errors/src/i18n/weblate/locales/en-GB.json.

Refs #671

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_0161qMQMsCyJhjYw4gqa6e4K
update_channel, update_channel_positions, follower_stats; update_member,
update_own_member, add/remove_member_role, kick_member, ban_member,
list_bans, unban_member, search_members; list_guild_invites,
delete_invite. USER_IS_NOT_BANNED and TIMEOUT_CANNOT_EXCEED_365_DAYS are
lifted out of INVALID_FORM_BODY like the entrance-sound codes.

Refs #671

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_0161qMQMsCyJhjYw4gqa6e4K
Author
Owner

Independent review: Task 5 (fluxer-api channels, members, bans, member search, invites)

Reviewed 7cd8bb1c..5f4dc7f8 cold, in a fresh worktree.

Tests named by the plan. All present: one wiremock test per method checks the method, path, body and answer. own_member_goes_to_me, kick_and_unban_204, member_search_post_body, user_is_not_banned_error and timeout_too_long_error are there. Request bodies are matched against Task 2/3's proto fixtures with body_json.

Interfaces. Every name in the Interfaces block exists with the stated shape: update_channel -> Channel, update_channel_positions (204), follower_stats, update_member -> GuildMember, update_own_member (/members/@me), add_member_role/remove_member_role (PUT/DELETE, 204), kick_member, ban_member, list_bans, unban_member, search_members (POST /members-search), list_guild_invites -> Vec<InviteMetadata> and delete_invite(code). Guild-channel deletion reuses delete_channel.

Invariants. All changes are in fluxer-api and stay transport only. list_bans drops entries it cannot read and does not panic. No secrets. Writes use Retry::Never.

Parity spot-checks against the fork.

  • Routes, methods and statuses match GuildMemberController.ts: PATCH members/@me answers with a GuildMemberResponse, member role PUT/DELETE, ban PUT and unban DELETE answer 204. InviteController.ts lists GET /guilds/:id/invites and DELETE /invites/:code (204). GuildChannelController.ts answers the PATCH on /guilds/:id/channels with 204.
  • USER_IS_NOT_BANNED comes from InputValidationError.fromCode('user_id', …) (GuildModerationService.ts:263). TIMEOUT_CANNOT_EXCEED_365_DAYS comes from fromCode('communication_disabled_until', …) (GuildMemberOperationsService.ts:603). Both arrive nested in INVALID_FORM_BODY, so the change to error.rs that lifts them out is justified. The fixtures' paths and codes match.
  • The kick sends no reason: KickMemberModal.tsx calls GuildMemberCommands.kick(guildId, targetUser.id) without one. This is spec §17 Q8's recommended answer.

Findings

  • minor: fixtures/errors/timeout_cannot_exceed_365_days.json has the message "…365 days from now.". The server calls fromCode without the maxDays variable, so the text it actually renders may differ. Callers act on the code, so this does not matter.
  • minor (process): src/error.rs is outside Task 5's Files list. The deviation is declared, is one ||, and should conflict only mechanically with Task 4.

Local gate: FLUXER_SCREENSHOT_TESTS=1 cargo xtask ci passed ("all steps passed", exit 0).

Verdict: APPROVED. No blocking findings; local CI is green.

## Independent review: Task 5 (fluxer-api channels, members, bans, member search, invites) Reviewed `7cd8bb1c..5f4dc7f8` cold, in a fresh worktree. **Tests named by the plan.** All present: one wiremock test per method checks the method, path, body and answer. `own_member_goes_to_me`, `kick_and_unban_204`, `member_search_post_body`, `user_is_not_banned_error` and `timeout_too_long_error` are there. Request bodies are matched against Task 2/3's proto fixtures with `body_json`. **Interfaces.** Every name in the Interfaces block exists with the stated shape: `update_channel -> Channel`, `update_channel_positions` (204), `follower_stats`, `update_member -> GuildMember`, `update_own_member` (`/members/@me`), `add_member_role`/`remove_member_role` (PUT/DELETE, 204), `kick_member`, `ban_member`, `list_bans`, `unban_member`, `search_members` (POST `/members-search`), `list_guild_invites -> Vec<InviteMetadata>` and `delete_invite(code)`. Guild-channel deletion reuses `delete_channel`. **Invariants.** All changes are in fluxer-api and stay transport only. `list_bans` drops entries it cannot read and does not panic. No secrets. Writes use `Retry::Never`. **Parity spot-checks against the fork.** - Routes, methods and statuses match `GuildMemberController.ts`: `PATCH members/@me` answers with a `GuildMemberResponse`, member role PUT/DELETE, ban PUT and unban DELETE answer 204. `InviteController.ts` lists `GET /guilds/:id/invites` and `DELETE /invites/:code` (204). `GuildChannelController.ts` answers the PATCH on `/guilds/:id/channels` with 204. - `USER_IS_NOT_BANNED` comes from `InputValidationError.fromCode('user_id', …)` (`GuildModerationService.ts:263`). `TIMEOUT_CANNOT_EXCEED_365_DAYS` comes from `fromCode('communication_disabled_until', …)` (`GuildMemberOperationsService.ts:603`). Both arrive nested in INVALID_FORM_BODY, so the change to `error.rs` that lifts them out is justified. The fixtures' paths and codes match. - The kick sends no reason: `KickMemberModal.tsx` calls `GuildMemberCommands.kick(guildId, targetUser.id)` without one. This is spec §17 Q8's recommended answer. **Findings** - minor: `fixtures/errors/timeout_cannot_exceed_365_days.json` has the message "…365 days from now.". The server calls `fromCode` without the `maxDays` variable, so the text it actually renders may differ. Callers act on the code, so this does not matter. - minor (process): `src/error.rs` is outside Task 5's Files list. The deviation is declared, is one `||`, and should conflict only mechanically with Task 4. **Local gate:** `FLUXER_SCREENSHOT_TESTS=1 cargo xtask ci` passed ("all steps passed", exit 0). **Verdict: APPROVED.** No blocking findings; local CI is green.
Author
Owner

Merged into serveradmin by hand (the merge API returns 405); the commits are in the branch.

Merged into `serveradmin` by hand (the merge API returns 405); the commits are in the branch.
charles closed this pull request 2026-11-15 22:47:24 +00:00

Pull request closed

Sign in to join this conversation.
No description provided.