docs: document the direct messaging contract - #258
Merged
Conversation
Adds `docs/direct-messaging.md`: the client-facing surface of the DM feature - lifecycle, endpoints, response objects, cursor semantics, the two-step media upload, realtime events, error titles and rate limits. It is written as reference material rather than as a hand-off note, since the repository is public and this is the document a client integrator lands on. A few behaviours are documented because they are invisible from an endpoint signature and will otherwise be discovered as bugs: `POST /conversations` answers 200 when the conversation already existed, the unread badge excludes requests, `conversation:request` is a different event from `message:new`, and message media has to come from `POST /messages/media` rather than the post upload endpoint. Removes `docs/media-moderation-client.md`. It was written in Turkish as a note to one frontend team, complete with instructions about not writing code before approval - not something that belongs in a public repository. The part of it that message media actually depends on, the upload error contract, is carried over into the new document. Co-Authored-By: Claude Opus 5 <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_011nFtPcaUsKpJwiUV2Hk9EY
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Summary
Adds
docs/direct-messaging.md, the client-facing contract for the direct messaging feature merged in #257, and removesdocs/media-moderation-client.md.The new document covers the conversation lifecycle, every endpoint with its request and response shapes, the conversation and message objects, cursor semantics, the two-step media upload, realtime events, error titles and rate limits. It is written as reference material — no team-directed instructions, no narration of backend internals — because this repository is public and this is the page a client integrator lands on.
Why this document exists
Pointing an integrator at the pull request does not work well. #257 is 89 files and roughly 6,700 lines, and most of it — entities, repositories, migrations, DI wiring, the moderation worker — is not part of the client contract. The contract itself lives in four schema and route files, and several rules that break a client are not visible from an endpoint signature at all:
POST /conversationsanswers200, not201, when the conversation already existed. Anything keyed on201alone misreads a no-op as a fresh thread.GET /conversations/unread-countexcludes pending requests, so it cannot back a request-tab badge.conversation:requestandmessage:neware separate events; the first must not raise the unread badge.403until they accept.POST /messages/media. A URL from the post upload endpoint is refused with400 MediaNotOwnedError, because the moderation channel is fixed at upload time.404, not403.mediaPending,mediaRejected,isDeletedandisSensitiveare four independent render states.Each of these is stated explicitly, with the reasoning where the reasoning is what makes the rule stick.
Why the old document is removed
docs/media-moderation-client.mdwas written in Turkish as a hand-off note to one frontend team. It narrated backend internals, told the reader not to guess and not to write code before approval, and closed with a section on working method. That is a message, not documentation, and it sat in a public repository alongside an otherwise English codebase.The part of it that message media genuinely depends on — the upload error contract, the magic-byte format detection, the tiered verdicts — is carried over into the new document's media section.
This does leave the post, article-cover, avatar and banner upload endpoints without a written client contract. If that is wanted, it belongs in its own reference page rather than in a note; happy to write one.
Verification
Documentation only — no source changes beyond a one-line pointer added to the direct messaging section of
CLAUDE.md.Every statement was checked against the merged implementation: status codes and error titles against the error classes and route schemas, field names against the mappers, limits and defaults against the TypeBox schemas, accepted media formats against
detect-media-type.ts, and the realtime event names and socket envelope againstchat-events.constants.tsandfastify-realtime.service.ts. No references to the removed file remain anywhere in the repository.AI asistan: Opus 5