Text chat 6: api-chat-endpoints (#256) #300
Loading…
Add table
Add a link
Reference in a new issue
No description provided.
Delete branch "textchat-6-api-chat-endpoints"
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?
What this builds
Text chat Task 6: the chat endpoints of spec §3.1 on
ApiClient(crates/fluxer-api/src/{reactions,pins,search,saved,dms,expressions,threads,settings}.rs):add_reaction,remove_own_reaction,remove_user_reaction,remove_emoji_reactions,remove_all_reactions,reaction_users(channel, message, &emoji, after, limit) -> ReactionUsersPage. The emoji path segment isReactionEmoji::path_segment().pins(channel, &PinsQuery) -> PinsPage,pin,unpin,ack_pins.search_messages(&SearchRequest) -> SearchResponse(HTTP 200{indexing: true}reads asIndexing).saved_messages(limit, before),save_message,unsave_message,recent_mentions(&MentionsQuery).create_group_dm,add_recipient,remove_recipient,edit_channel(icon as a data URI ornull),close_channel,relationships().patch_user_settings(&UserSettingsPatch) -> UserSettings. It is never retried, so aSYNCED_PREFERENCES_CONFLICTcomes back as it is.gifs_featured/trending(locale),gifs_search/suggest(q, locale),gif_register_share(id, q, locale). The query and body match the original'slocalizedQuery/gifShareBody.memes(),save_meme_from_message(channel, message, &SaveMemeRequest),delete_meme(id). Guild expressions:guild_emojis(guild),guild_stickers(guild).create_thread_from_message,create_thread,active_threads(guild) -> ActiveThreads,join_thread,leave_thread.ack(channel, message, manual: bool):{"manual": true}when manual, otherwise{}as before.Retry policy follows the crate's rule: only
GETs are sent again after a 429. Everything else surfacesRateLimited.How it was tested
crates/fluxer-api/tests/chat.rs(13 tests) andtests/expressions.rs(3 tests) run against wiremock with the REST fixtures from Text chat 2/3:reaction_path_encodes_unicode_and_custom,reaction_users_paging,pins_query_and_page,search_indexing_then_results,group_dm_create_and_recipients,edit_channel_icon_data_uri,patch_user_settings_only_set_fields,gif_endpoints_send_locale,thread_create_from_message,manual_ack_body. There are also tests for saved messages and mentions, active threads, memes, guild emoji and stickers, the settings conflict and a 429 on a reaction.FLUXER_SCREENSHOT_TESTS=1 cargo xtask ciis green locally. No desktop tests apply.Deviations from the plan
fluxer-protogained two small types the Interfaces block uses but no earlier task defines, plus one contract check:SaveMemeRequest(CreateFavoriteMemeBodySchema), checked against the vendored OpenAPI inspec_contract.rs.ActiveThreads(ActiveThreadsResponse).ackgained themanualargument, so its three callers now passfalse:apps/fluxer/src/runtime.rs,crates/fluxer-devserver/tests/scenario.rsandcrates/fluxer-api/tests/messages.rs. The manual body is{"manual": true}as the plan says. The original also sendsmention_count: 0, which the server treats as optional.active_threadshas no new fixture: its test builds{threads, members}fromfixtures/rest/thread_created.json, somodels_roundtrip's fixture registry stays untouched.fluxer-proto:events.rsvariants/imports and dispatch-name counts (now 60 typed + 24 untyped = 84),channel.rsfields,settings.rsaccessors,models_roundtrip.rslists, README. I resolved them by keeping both sides. Please look at the merge commit.Stacked on: textchat-2-proto-chat-requests-events, textchat-3-proto-expressions-threads-prefs
Closes #256
🤖 Generated with Claude Code
Failing tests for Text chat 3 (expressions.rs, threads.rs, prefs.rs) and the fixtures they read, each shaped from the fork at ba98441b4: - gateway/guild_emojis_update.json, guild_stickers_update.json: fluxer_api/src/api/guild/services/content/EmojiService.ts:301-307 and StickerService.ts:342-348 ({emojis}/{stickers} via mapGuildEmojiToResponse / mapGuildStickerToResponse, guild/GuildModel.ts:98-118), guild_id added by fluxer_gateway/src/guild/guild_dispatch.erl:91. - gateway/thread_create.json, thread_update.json, thread_delete.json, thread_members_update.json, thread_member_update.json: fluxer_api/src/api/channel/services/thread/ThreadDispatch.ts:26-93 (thread object from ThreadMappers.ts:42-92); the internal _fluxer_* keys are stripped by guild_dispatch.erl:131-136 / guild_thread_payload.erl:139-146. - gateway/thread_list_sync.json: fluxer_gateway/src/guild/guild_thread_view.erl:100-123. - gateway/favorite_meme_create.json, favorite_meme_delete.json: fluxer_api/src/api/favorite_meme/FavoriteMemeService.ts:213-218, 454-458 and FavoriteMemeModel.ts:9-32. - gateway/user_settings_update_prefs.json: fluxer_api/src/api/user/services/UserAccountUpdatePropagator.ts:17-23, user/UserMappers.ts:296-375. - rest/guild_emojis.json, guild_stickers.json: GuildEmojiController.ts:111-133 (GuildEmojiWithUserResponse, packages/schema/src/domains/guild/GuildEmojiSchemas.ts:9-39). - rest/gifs_featured.json, gifs_search.json: packages/schema/src/domains/gif/GifSchemas.ts:36-88, fluxer_gifs/src/types.rs:70-100 (placeholder left out when absent). - rest/memes.json: FavoriteMemeModel.ts:9-32 (nullable fields written as null). - rest/thread_created.json: ThreadController.ts:134-169 (201 ThreadChannelResponse), ThreadMappers.ts:19-41 (own member: muted, mute_config null), 58-92. - prefs/synced_preferences.b64: encoded by the fork's own protobuf-es encoder (packages/schema/src/gen/fluxer/user/preferences/v1/*_pb.ts, packages/schema/src/domains/user/SyncedPreferencesCodec.ts), run read-only; how is in fixtures/prefs/README.md. Refs #253 Co-Authored-By: Claude Fable 5.2 <noreply@anthropic.com>Gateway fixtures, shaped from the fork's server at ba98441b4: - message_reaction_add (DM, session_id kept): fluxer_api/src/api/channel/ services/interaction/MessageReactionService.ts:431-449, dispatched as is by ChannelGatewayDispatch.ts:46-50 - message_reaction_add_guild, message_reaction_remove (guild_id added, member with user, session_id stripped): fluxer_gateway/src/guild/ guild_dispatch.erl:91,146-149 and guild_dispatch_decorate.erl:36-46,63-66 - message_reaction_add_many: fluxer_gateway/src/session/ session_dispatch_voice.erl:157-195 - message_reaction_remove_all / _remove_emoji: MessageReactionService.ts:472-500 - message_delete_bulk: channel/services/message/MessageGatewayDispatch.ts:140-158 - channel_pins_update: channel/services/interaction/MessagePinService.ts:253-262 - channel_pins_ack: read_state/ReadStateService.ts:266-281 - channel_recipient_add / _remove: channel/services/group_dm/ GroupDmOperationsService.ts:207-216,288-296 - saved_message_create (d is the MessageResponse itself), saved_message_delete, recent_mention_delete: user/services/UserContentService.ts:114-123,897-981 - relationship_add: user/services/UserRelationshipService.ts:703-720 via user/UserMappers.ts:375-394; relationship_remove ({id} only): :742-748 - message_update_unfurl (full message, member without user): guild_dispatch_decorate.erl:36-41 REST fixtures: - presigned_uploads: channel/services/AttachmentUploadService.ts:228-285 - pins_page: packages/schema/src/domains/message/MessageResponseSchemas.ts:177-194 - reaction_users: MessageResponseSchemas.ts:200-204 - search_results / search_indexing (HTTP 200): MessageResponseSchemas.ts:208-233 - saved_messages: user/services/UserContentRequestService.ts:166-174, packages/schema/src/domains/user/UserResponseSchemas.ts:591-614 - mentions: MessageListResponse (MessageResponseSchemas.ts:237) - relationships: UserMappers.ts:375-394, UserResponseSchemas.ts:492-505 - group_dm: ChannelSchemas.ts (nicks at :105-108) Refs #252 Co-Authored-By: Claude Fable 5.2 <noreply@anthropic.com>Requests: SendMessageRequest gains message_reference, allowed_mentions, flags, attachments, sticker_ids, favorite_meme_id and tts (all left off the wire at their default, so a plain send is still {content, nonce} byte for byte); MessageReferenceRequest, AllowedMentions/MentionParse, AttachmentPayload/AttachmentPayloadId (ids as decimal strings, as the original sends them), EditMessageRequest with optional content, flags and attachments; the presigned upload flow (PresignRequest, PresignResponse with SecretString URLs and redacting Debug, CompleteUploadsRequest); PinsQuery / PinsPage; ReactionUsersPage; SearchRequest / SearchResponse::{Results, Indexing}; SavedMessage, SaveMessageRequest, MentionsQuery; CreateGroupDmRequest, EditChannelRequest, Channel.nicks; Relationship; UserSettings accessors and UserSettingsPatch. Gateway: MESSAGE_REACTION_ADD|ADD_MANY|REMOVE|REMOVE_ALL|REMOVE_EMOJI, CHANNEL_PINS_UPDATE|ACK, CHANNEL_RECIPIENT_ADD|REMOVE, SAVED_MESSAGE_CREATE|DELETE, RECENT_MENTION_DELETE, RELATIONSHIP_ADD|UPDATE|REMOVE typed; MESSAGE_DELETE_BULK gains guild_id; READY.relationships typed. Request bodies are checked against their OpenAPI request schemas. The struct-literal changes in fluxer-api and fluxer-devserver tests, apps/fluxer's runtime and fluxer-core's MESSAGE_DELETE_BULK match are the minimum needed to compile against the new shapes. Refs #252 Co-Authored-By: Claude Fable 5.2 <noreply@anthropic.com>SaveMemeRequest is CreateFavoriteMemeBodySchema (packages/schema/src/domains/meme/MemeSchemas.ts:20-25), checked against the vendored OpenAPI schema. ActiveThreads is ActiveThreadsResponse (packages/schema/src/domains/channel/ThreadRequestSchemas.ts:109-112), the answer of GET /guilds/{g}/threads/active (ThreadController.ts:230-243). Refs #256 Co-Authored-By: Claude Fable 5.2 <noreply@anthropic.com>ApiClient gains the text chat endpoints of spec §3.1: reactions and reaction users, pins and the pins ack, message search (indexing answer included), bookmarks and recent mentions, group DMs, recipients, channel edit and close, relationships, the user settings patch, GIFs (with the UI locale), saved media, guild emoji and stickers, and threads. ack() takes a manual flag and sends {"manual": true} for "Mark as unread"; its three callers pass false. Refs #256 Co-Authored-By: Claude Fable 5.2 <noreply@anthropic.com>Independent review: Text chat 6 (api-chat-endpoints), head
b3179a2I reviewed
git diff 3bcf92d..origin/textchat-6-api-chat-endpointswithout relying on the implementer's notes.Local gate:
FLUXER_SCREENSHOT_TESTS=1 cargo xtask ciin a clean review worktree exited 0 (green).What I checked and found correct
reaction_path_encodes_unicode_and_custom,reaction_users_paging,pins_query_and_page,search_indexing_then_results,group_dm_create_and_recipients,edit_channel_icon_data_uri,patch_user_settings_only_set_fields,gif_endpoints_send_locale,thread_create_from_messageandmanual_ack_body. The PR also adds 6 extra tests.ApiClientwith the planned name and arguments.ack(channel, message, manual)is updated at all three call sites.MessageInteractionController.ts(reactions, pins, pins ack),ThreadController.ts(create, active, thread-members/@me) andChannelController.ts(recipients, PATCH/DELETE channel).UserContentController.ts(saved-messages, mentions),FavoriteMemeController.ts,GifController.ts(GifSearchQuery, GifLocaleQuery, GifRegisterShareRequest),SearchController.tsandUserAccountController.ts(settings).SaveMemeRequestmatchesCreateFavoriteMemeBodySchemaand has a spec_contract check.ActiveThreadsmatchesActiveThreadsResponse.Findings
edit_channelputs file content into--recordoutput (crates/fluxer-api/src/dms.rs).edit_channelgoes through the observed client. Withicon: Some(Some(data URI)), the request body carries the user's image file as base64. The observer records that body, andrecord.rs::redactonly removes secret keys and*_token.--recordoutput".self.unobserved().execute_json(...), asstreams.rsdoes, either always or wheniconisSome(Some(_)). Add a test that the observer never sees the data URI, in the style of Task 5'sobserver_never_sees_upload_urls. The existing soundboard upload has the same pattern and predates this constraint; it could be a follow-up issue.mention_count(crates/fluxer-api/src/messages.rs).sendManualAck(fluxer_app/src/features/read_state/state/ReadStates.ts:369-377) sendsmention_countwithmanual: true.MessageController.ts:576-581) defaults a missingmention_countto 0. So "Mark as unread" on a message that mentions the user resets the server-side mention badge to 0.{manual}, so this is not a contract break. It is worth a follow-up issue so that Task 16 can pass the count.active_threadshas no fixture of its own. Its test builds the response fromthread_created.json. The shape matchesActiveThreadsResponse, so this is acceptable. Afixtures/rest/active_threads.jsonwould make it easier for the devserver (Task 20) to reuse.I did not review merge commit 3bcf92d's conflict resolution line by line. It is outside this diff, and the full CI on the head, which includes the fluxer-proto dispatch-count tests, is green.
Verdict: changes requested. There is one blocking finding (#1), a one-line fix plus a test. Everything else is correct and CI is green.
edit_channel now goes through the unobserved client, as the stream preview endpoints do: a group DM icon is the user's image as a base64 data: URI, and no file content may reach the observer. A test records every exchange the observer sees and checks the icon is not among them. fixtures/rest/active_threads.json gives GET /guilds/{id}/threads/active its own fixture, shaped from the fork at ba98441b4: fluxer_api/src/api/channel/services/thread/ThreadListService.ts:165-179 (threads mapped by mapThreadToResponse without a viewer member, so no `member` key, newest first; members with self fields) and packages/schema/src/domains/channel/ThreadRequestSchemas.ts:109-112. The proto round-trip covers it. Refs #256 Co-Authored-By: Claude Fable 5.2 <noreply@anthropic.com>Review round 1 addressed in
31b48f6.Blocking:
edit_channelobserved (crates/fluxer-api/src/dms.rs). Fixed.edit_channelnow builds and sends its request throughself.unobserved(), asstreams.rsdoes, so the group DM icon'sdata:URI never reaches the observer /--record. Test first:edit_channel_icon_is_not_observedincrates/fluxer-api/tests/chat.rsrecords every exchange the observer is shown and asserts the icon bytes are absent; it failed before the change and passes now. Theunobserved()doc comment names group DM icons as a reason.Minor: manual ack without
mention_count(crates/fluxer-api/src/messages.rs). Deferred to follow-up #303: changingack's signature reaches into its callers and Text chat 16's interface, so it is better done there. The issue citesReadStates.ts:369-377and the legacy fallback atReadStates.ts:950-971(which also sendsmention_countto the per-message ack), and notes that the original triesPOST /read-states/ackfirst.Minor: no
active_threadsfixture (crates/fluxer-api/tests/chat.rs). Fixed. Addedfixtures/rest/active_threads.json, shaped from the fork at ba98441b4 (ThreadListService.ts:165-179,ThreadRequestSchemas.ts:109-112). It has two threads, newest first, with nomemberkey on the threads, becausemapThreadToResponsegets no viewer member on this route, and one self membership carryingmuted/mute_config. The API test now serves it, and thefluxer-protoround-trip and unknown-fields tables cover it.FLUXER_SCREENSHOT_TESTS=1 cargo xtask ciis green locally. One earlier run hit an intermittent SIGSEGV at exit in thefluxerlib test binary after all 53 tests had passed. It is unrelated to this change and is filed as #304.(An earlier comment posted here by mistake, a stale review text for Text chat 9, has been deleted.)
Independent review (round 2): Text chat 6 (api-chat-endpoints), head
31b48f6I reviewed
git diff 3bcf92d..origin/textchat-6-api-chat-endpointscold, then checked the implementer's notes against it.Local gate:
FLUXER_SCREENSHOT_TESTS=1 cargo xtask ciin a clean review worktree (tc-review-6) exited 0 ("all steps passed").What I checked and found correct
crates/fluxer-api/tests/{chat,expressions}.rsand assert what the plan says:reaction_path_encodes_unicode_and_custom:%F0%9F%91%8D,name%3Aid, all 6 reaction routes.reaction_users_paging:limit/after, andnext_afteris fed back.pins_query_and_page: an ISObefore.search_indexing_then_results: HTTP 200{indexing:true}, then results.group_dm_create_and_recipients,edit_channel_icon_data_uri.patch_user_settings_only_set_fields: exactbody_json.gif_endpoints_send_locale: all 5 GIF endpoints.thread_create_from_message,manual_ack_body.edit_channel_icon_is_not_observed, active threads, memes, emoji/stickers, the settings conflict, a reaction 429.ApiClientwith the planned name and arguments, includingack(channel, message, manual: bool). Its 3 callers passfalse.MessageInteractionController.ts: reactions,messages/pins,pins/:message_id,pins/ack.ThreadController.ts:threads/active,thread-members/@me(204), creates (201).ChannelController.ts: recipients, PATCH/DELETE/channels/:id.UserContentController.ts: saved-messages (POST 204), mentions.FavoriteMemeController.ts: list is an array, the create from a message is 201.GifController.ts:suggestandsearchtakeGifSearchQuery {q, locale}.GuildEmojiController.ts/GuildStickerController.ts.edit_channelbuilds and sends throughself.unobserved(). The new test records every exchange the observer sees and asserts thedata:URI is absent. The client's tracing logs only status and retry_after, never bodies.fixtures/rest/active_threads.jsonmatches the server. It matchesThreadListService.respond:mapThreadToResponsewithout a viewer member, so threads have nomemberkey, andmapThreadMemberToResponse(self)givesmutedand a nullablemute_config. It also matchesThreadMemberResponse. The commit message names the files and lines it was shaped from. It is registered inmodels_roundtrip.rsfor the round trip, unknown fields, ignoredflagsand defaulted fields.ActiveThreadsuseslenient_vec.mention_count) exists with labelfollow-up. The stray comment 4557 is gone.Findings
active_threadshas no new fixture", but31b48f6adds one.mention_count: 0, which the server treats as optional". The original sends the computed count (ReadStateCommands.ts:48-53,getManualAckMentionCount); see #303.fluxer-protogainedSaveMemeRequestandActiveThreads, andapps/fluxer/fluxer-devservercallers changed for theacksignature. All of it is small, needed by the Interfaces block, and stated in the PR. I record it only because CLAUDE.md asks for cross-crate tasks to say so in the plan.mention_count. This is tracked in #303, so nothing to do here. The behaviour matches the plan's Interfaces text.Verdict: approved. There are no blocking findings, CI is green locally, and the round-1 blocking finding is fixed with a test.