Daily use 5: fluxer-api relationships, invites, guilds, member voice (#489) #547

Closed
charles wants to merge 0 commits from dailyuse-5-api-relationships-invites-guilds into dailyuse
Owner

What this builds

fluxer-api endpoints for Daily use spec §3.5, §3.6 and §3.8 (plan Task 5):

  • relationships.rs: send_friend_request_by_tag(&FriendRequestByTag), send_friend_request(user) (POST …/{id} {}), accept_friend_request(user) (PUT, no body), block_user(user) (PUT {type: 2}), remove_relationship(user) (DELETE: remove, ignore, cancel, unblock), set_friend_nickname(user, Option<String>) (PATCH, null to clear). relationships() moved here from dms.rs, unchanged.
  • invites.rs: invite(code) -> InviteResponse (no Authorization: the server route is security: []), accept_invite(code) -> InviteResponse (POST {}), create_channel_invite(channel, &ChannelInviteCreate) -> InviteMetadata, channel_invites(channel) -> Vec<InviteMetadata>.
  • guilds.rs: create_guild(&GuildCreateRequest) -> Guild (not shown to the --record observer, its icon is a data URI, like edit_channel), leave_guild(guild, delete_messages) (query only when true), update_member_voice(guild, user, &MemberVoicePatch) -> () (#134).
  • dms.rs: leave_group_dm(channel, silent, delete_messages) (DELETE /channels/{id}, each flag only when true).
  • Refusals keep their API code in ApiError::Http (tests for relationship codes, UNKNOWN_INVITE, USER_NOT_IN_VOICE, UNCLAIMED_ACCOUNT_CANNOT_CREATE_GUILDS).

Tests

crates/fluxer-api/tests/{relationships,invites,guilds}.rs (wiremock, 20 tests): every plan test name, plus send_to_known_user_posts_empty_object, invite_get_group_dm, unknown_invite_keeps_its_code, channel_invites_list, list_moved_unchanged. Bodies are checked against the Task 2 fixtures (relationship_add_by_tag.json, relationship_errors.json, invite_*.json, guild_create.json, member_voice_patch.json). Seen failing (no such methods) before the implementation. FLUXER_SCREENSHOT_TESTS=1 cargo xtask ci green locally. No display tests involved (none run).

Deviations from the plan

  • Relationship POST/PUT/PATCH and the member PATCH return (): the server answers with the relationship/member, but the original does not read it (gateway events carry the change), and a decode failure must not turn a done change into an error. The plan gave no return type for these.
  • One small addition outside the Files list: client.rs gains pub(crate) fn anonymous() (the client without its token) for the unauthenticated invite GET.
  • CANNOT_LEAVE_GUILD_AS_OWNER arrives nested in INVALID_FORM_BODY.errors[]; ApiError::classify only lifts entrance-sound codes, so it surfaces as INVALID_FORM_BODY. The leave item is hidden for the owner (spec §3.6), so it was left as is.

Stacked on: dailyuse-2-proto-relationships-invites-reports

Closes #489

🤖 Generated with Claude Code

## What this builds `fluxer-api` endpoints for Daily use spec §3.5, §3.6 and §3.8 (plan Task 5): - `relationships.rs`: `send_friend_request_by_tag(&FriendRequestByTag)`, `send_friend_request(user)` (`POST …/{id}` `{}`), `accept_friend_request(user)` (`PUT`, no body), `block_user(user)` (`PUT` `{type: 2}`), `remove_relationship(user)` (`DELETE`: remove, ignore, cancel, unblock), `set_friend_nickname(user, Option<String>)` (`PATCH`, `null` to clear). `relationships()` moved here from `dms.rs`, unchanged. - `invites.rs`: `invite(code) -> InviteResponse` (no `Authorization`: the server route is `security: []`), `accept_invite(code) -> InviteResponse` (`POST` `{}`), `create_channel_invite(channel, &ChannelInviteCreate) -> InviteMetadata`, `channel_invites(channel) -> Vec<InviteMetadata>`. - `guilds.rs`: `create_guild(&GuildCreateRequest) -> Guild` (not shown to the `--record` observer, its icon is a data URI, like `edit_channel`), `leave_guild(guild, delete_messages)` (query only when true), `update_member_voice(guild, user, &MemberVoicePatch) -> ()` (#134). - `dms.rs`: `leave_group_dm(channel, silent, delete_messages)` (`DELETE /channels/{id}`, each flag only when true). - Refusals keep their API `code` in `ApiError::Http` (tests for relationship codes, `UNKNOWN_INVITE`, `USER_NOT_IN_VOICE`, `UNCLAIMED_ACCOUNT_CANNOT_CREATE_GUILDS`). ## Tests `crates/fluxer-api/tests/{relationships,invites,guilds}.rs` (wiremock, 20 tests): every plan test name, plus `send_to_known_user_posts_empty_object`, `invite_get_group_dm`, `unknown_invite_keeps_its_code`, `channel_invites_list`, `list_moved_unchanged`. Bodies are checked against the Task 2 fixtures (`relationship_add_by_tag.json`, `relationship_errors.json`, `invite_*.json`, `guild_create.json`, `member_voice_patch.json`). Seen failing (no such methods) before the implementation. `FLUXER_SCREENSHOT_TESTS=1 cargo xtask ci` green locally. No display tests involved (none run). ## Deviations from the plan - Relationship `POST`/`PUT`/`PATCH` and the member `PATCH` return `()`: the server answers with the relationship/member, but the original does not read it (gateway events carry the change), and a decode failure must not turn a done change into an error. The plan gave no return type for these. - One small addition outside the Files list: `client.rs` gains `pub(crate) fn anonymous()` (the client without its token) for the unauthenticated invite `GET`. - `CANNOT_LEAVE_GUILD_AS_OWNER` arrives nested in `INVALID_FORM_BODY.errors[]`; `ApiError::classify` only lifts entrance-sound codes, so it surfaces as `INVALID_FORM_BODY`. The leave item is hidden for the owner (spec §3.6), so it was left as is. Stacked on: dailyuse-2-proto-relationships-invites-reports Closes #489 🤖 Generated with [Claude Code](https://claude.com/claude-code)
Fork ba98441b4 sources, each fixture copied from the server's shape:
- relationship_add_by_tag.json: FriendRequestByTagRequest as the client sends it
  (fluxer_app/src/features/relationship/commands/RelationshipCommands.ts:33)
- relationship_errors.json: FluxerError.toJSON {code, message}
  (packages/errors/src/FluxerError.ts:50-56; messages from errors i18n weblate/messages.json)
- invite_guild.json, invite_group_dm.json, invite_metadata.json:
  fluxer_api/src/api/invite/InviteModel.ts:43-174 (mapInviteTo*Response), guild from
  fluxer_api/src/api/guild/GuildModel.ts:29-52, channel from ChannelMappers.ts:247-253
- invite_unknown.json: UnknownInviteError body (unknown_entities.unknown_invite)
- guild_create.json: mapGuildToGuildResponse, fluxer_api/src/api/guild/GuildModel.ts:54-80
- read_states_ack.json: ReadStateAckRequest,
  packages/schema/src/domains/channel/ChannelRequestSchemas.ts:440-452
- member_voice_patch.json: GuildMemberUpdateRequest voice fields,
  packages/schema/src/domains/guild/GuildRequestSchemas.ts:157-166
- report_flow_message.json: getReportFlowResponse / renderScreen,
  fluxer_api/src/api/report/flows/ReportFlowRegistry.ts:136-210, a trimmed walk of the
  message flow of ReportFlowScreens.ts:60-460 with the English copy of content_i18n
- report_submission.json: ReportFlowMessageSubmissionRequest,
  packages/schema/src/domains/report/ReportFlowSchemas.ts:129-149
- profile_connections.json: ConnectionResponse in the profile,
  fluxer_api/src/api/user/services/UserAccountRequestService.ts:400-441,
  fluxer_api/src/api/connection/ConnectionMappers.ts:6-15
- user_note.json, user_notes.json: UserNoteResponse / UserNotesRecordResponse,
  packages/schema/src/domains/user/UserResponseSchemas.ts:705-713
- gateway/user_note_update.json: fluxer_api/src/api/user/services/UserAccountUpdatePropagator.ts:35-42

Refs #487

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Daily use Task 2 (Task 3 merged in): FriendRequestByTag, RelationshipPut,
RelationshipNickname and the voice-activity flags of Relationship; API error
bodies and codes (fluxer_proto::errors); InviteResponse/InviteMetadata,
ChannelInviteCreate, Endpoints::invite; GuildCreateRequest, leave queries,
MemberVoicePatch; ReadStatesAck and AckBody; the report flow, submission and
legacy report; typed connected accounts, user notes and USER_NOTE_UPDATE;
MessageReferenceRequest.attachment_ids/embed_indices (no longer Copy, so
fluxer-core's three builders and their tests clone or fill the new fields).

Refs #487

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Endpoints on ApiClient: friend requests (by tag and by id), accept,
block, remove/ignore/cancel/unblock, friend nickname; invite (sent
without the token, GET /invites/{code} is public), accept_invite,
create_channel_invite, channel_invites; create_guild, leave_guild,
leave_group_dm; update_member_voice (#134). relationships() moves from
dms.rs to relationships.rs unchanged. Tests use the Task 2 fixtures
(relationship_add_by_tag, relationship_errors, invite_*, guild_create,
member_voice_patch).

Refs #489

Co-Authored-By: Claude Fable 5.2 <noreply@anthropic.com>
Author
Owner

Independent review: Daily use 5 (fluxer-api relationships, invites, guilds, member voice)

Scope: git diff 2763b5f..origin/dailyuse-5-api-relationships-invites-guilds (d849396).

Checks

  1. Plan tests: all 14 named tests exist and assert what the plan says (bodies matched with body_json against the Task 2 fixtures; no-body checked for accept and DELETE; no Authorization on the invite GET; {max_age: 604800, max_uses: 0, temporary: false}; leave query flags sent only when true, with no bare ?; channel_id: null on disconnect; USER_NOT_IN_VOICE and the add-friend codes kept in ApiError::Http).
  2. Interfaces: every name and signature in the Task 5 block exists as written (send_friend_request_by_tag, send_friend_request, accept_friend_request, block_user, remove_relationship, set_friend_nickname(user, Option<String>), invite(code), accept_invite, create_channel_invite, channel_invites, create_guild, leave_guild(guild, bool), leave_group_dm(channel, silent, delete_messages), update_member_voice(...) -> ()). relationships() was moved, not changed.
  3. Invariants: only fluxer-api changed. No secrets: the test token is the existing placeholder, create_guild stays unobserved (the icon is a data URI), and anonymous() only removes the token. Nothing in the changes can panic.
  4. Parity, checked in the fork: RelationshipCommands.ts:29-46 (POST {}, by tag {username, discriminator}, PUT with no body, PUT {type: 2}, DELETE, PATCH {nickname}), ChannelCommands.ts:88-92 and GuildCommands.ts:341 (query flags only when true), InviteModal.tsx:280 (604800/0/false), InviteCommands.tsx:311,322 and ACCEPT_INVITE_BODY = {}, GuildMemberCommands.ts:35. All match.
  5. Review Focus: no item belongs to Task 5.
  6. FLUXER_SCREENSHOT_TESTS=1 cargo xtask ci in the review worktree: green ("all steps passed"; the new guilds, invites and relationships suites ran).

Findings

  • [minor] invite() drops the token, as the spec requires (§3.6 "no auth"). The original's instanceRequest does send it on the same instance, though, and the server uses the caller's id in withVisitsOffer (InviteRequestService.ts:45,65; GuildVisitsGate.ts:24-39). An anonymous GET can therefore come back without visits_enabled (or with a different value) for a user in the visits experiment. This has no effect today, because §17 Q11 joins instead of previewing. It is a deliberate divergence and should be recorded in spec §13 or docs/parity/dailyuse.md.
  • [minor] CANNOT_LEAVE_GUILD_AS_OWNER is raised as a field error inside INVALID_FORM_BODY (GuildMemberOperationsService.ts:547). ApiError::Http keeps only the top-level code and the message, so the core cannot see the field code, even though fluxer_proto::errors::ApiErrorBody can find it. There is no behaviour loss: the original shows the generic "Failed to leave community" and hides the item for owners. Fine as long as no later task maps this code from ApiError.
  • [minor] invite_url encodes the code with form_urlencoded::byte_serialize, which turns a space into + (a literal + in a path). Raw text from the Join modal that is not a regex code therefore reaches the server as a+b, where the original's fetch sends a%20b. Both come back as an unknown invite, so the only effect is that the path is different.

Verdict: approve (0 blocking, 3 minor; local CI green).

🤖 Generated with Claude Code

## Independent review: Daily use 5 (fluxer-api relationships, invites, guilds, member voice) Scope: `git diff 2763b5f..origin/dailyuse-5-api-relationships-invites-guilds` (d849396). **Checks** 1. Plan tests: all 14 named tests exist and assert what the plan says (bodies matched with `body_json` against the Task 2 fixtures; no-body checked for accept and DELETE; no `Authorization` on the invite GET; `{max_age: 604800, max_uses: 0, temporary: false}`; leave query flags sent only when true, with no bare `?`; `channel_id: null` on disconnect; `USER_NOT_IN_VOICE` and the add-friend codes kept in `ApiError::Http`). 2. Interfaces: every name and signature in the Task 5 block exists as written (`send_friend_request_by_tag`, `send_friend_request`, `accept_friend_request`, `block_user`, `remove_relationship`, `set_friend_nickname(user, Option<String>)`, `invite(code)`, `accept_invite`, `create_channel_invite`, `channel_invites`, `create_guild`, `leave_guild(guild, bool)`, `leave_group_dm(channel, silent, delete_messages)`, `update_member_voice(...) -> ()`). `relationships()` was moved, not changed. 3. Invariants: only fluxer-api changed. No secrets: the test token is the existing placeholder, `create_guild` stays unobserved (the icon is a data URI), and `anonymous()` only removes the token. Nothing in the changes can panic. 4. Parity, checked in the fork: `RelationshipCommands.ts:29-46` (POST `{}`, by tag `{username, discriminator}`, PUT with no body, PUT `{type: 2}`, DELETE, PATCH `{nickname}`), `ChannelCommands.ts:88-92` and `GuildCommands.ts:341` (query flags only when true), `InviteModal.tsx:280` (604800/0/false), `InviteCommands.tsx:311,322` and `ACCEPT_INVITE_BODY = {}`, `GuildMemberCommands.ts:35`. All match. 5. Review Focus: no item belongs to Task 5. 6. `FLUXER_SCREENSHOT_TESTS=1 cargo xtask ci` in the review worktree: **green** ("all steps passed"; the new guilds, invites and relationships suites ran). **Findings** - [minor] `invite()` drops the token, as the spec requires (§3.6 "no auth"). The original's `instanceRequest` does send it on the same instance, though, and the server uses the caller's id in `withVisitsOffer` (`InviteRequestService.ts:45,65`; `GuildVisitsGate.ts:24-39`). An anonymous GET can therefore come back without `visits_enabled` (or with a different value) for a user in the visits experiment. This has no effect today, because §17 Q11 joins instead of previewing. It is a deliberate divergence and should be recorded in spec §13 or `docs/parity/dailyuse.md`. - [minor] `CANNOT_LEAVE_GUILD_AS_OWNER` is raised as a field error inside `INVALID_FORM_BODY` (`GuildMemberOperationsService.ts:547`). `ApiError::Http` keeps only the top-level `code` and the message, so the core cannot see the field code, even though `fluxer_proto::errors::ApiErrorBody` can find it. There is no behaviour loss: the original shows the generic "Failed to leave community" and hides the item for owners. Fine as long as no later task maps this code from `ApiError`. - [minor] `invite_url` encodes the code with `form_urlencoded::byte_serialize`, which turns a space into `+` (a literal `+` in a path). Raw text from the Join modal that is not a regex code therefore reaches the server as `a+b`, where the original's fetch sends `a%20b`. Both come back as an unknown invite, so the only effect is that the path is different. Verdict: **approve** (0 blocking, 3 minor; local CI green). 🤖 Generated with [Claude Code](https://claude.com/claude-code)
Author
Owner

Merged into dailyuse at 863726f (combined merge of the first twelve Daily use tasks).

Merged into `dailyuse` at 863726f (combined merge of the first twelve Daily use tasks).
charles closed this pull request 2026-11-14 13:03:59 +00:00

Pull request closed

Sign in to join this conversation.
No description provided.