Skip to content

docs: document the direct messaging contract - #258

Merged
aquie00t merged 1 commit into
mainfrom
docs/direct-messaging-client
Sep 3, 2026
Merged

docs: document the direct messaging contract#258
aquie00t merged 1 commit into
mainfrom
docs/direct-messaging-client

Conversation

@aquie00t

@aquie00t aquie00t commented Sep 3, 2026

Copy link
Copy Markdown
Collaborator

Summary

Adds docs/direct-messaging.md, the client-facing contract for the direct messaging feature merged in #257, and removes docs/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 /conversations answers 200, not 201, when the conversation already existed. Anything keyed on 201 alone misreads a no-op as a fresh thread.
  • GET /conversations/unread-count excludes pending requests, so it cannot back a request-tab badge.
  • conversation:request and message:new are separate events; the first must not raise the unread badge.
  • In a pending conversation only the initiator may post; the recipient gets 403 until they accept.
  • Message media must come from POST /messages/media. A URL from the post upload endpoint is refused with 400 MediaNotOwnedError, because the moderation channel is fixed at upload time.
  • A non-participant receives 404, not 403.
  • mediaPending, mediaRejected, isDeleted and isSensitive are 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.md was 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 against chat-events.constants.ts and fastify-realtime.service.ts. No references to the removed file remain anywhere in the repository.


AI asistan: Opus 5

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
@aquie00t
aquie00t merged commit 26b931a into main Sep 3, 2026
10 checks passed
@aquie00t
aquie00t deleted the docs/direct-messaging-client branch September 3, 2026 09:20
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant