Skip to main content

chat-service

Messages, direct messages, friends, E2EE key exchange, and uploads. The biggest service, and the only one with a WebSocket for message delivery.

/ws/chat

Socket.IO-style JSON messages, not @nestjs/websockets decorators — one gateway class handling frames itself.

Frame typeDirectionWhat it does
pingclient → serverKeepalive
channel.subscribeclient → serverJoin channel:<id> room (access re-checked)
channel.unsubscribeclient → serverLeave the room
server.subscribeclient → serverJoin server:<id> room (membership re-checked)
server.unsubscribeclient → serverLeave the room
message.created / message.updatedserver → clientNew message, or an edit/delete/pin/reaction on an existing one
friends.changedserver → clientRe-fetch the friends list
server.members.changedserver → clientRe-fetch a server's member list

See Events for why edits, deletes, pins and reactions all arrive as one message.updated shape.

/api/v1/messages

MethodPathWhat it does
GET/Page a channel's history
GET/unfurlLink preview metadata
GET/pinsA channel's pinned messages
POST/Send a message
PATCH/:messageIdEdit (author only)
DELETE/:messageIdDelete (author, or DELETE_MESSAGE)
PUT/:messageId/pinPin (MANAGE_MESSAGE in a server channel, free in a DM)
DELETE/:messageId/pinUnpin
POST/:messageId/reactionsReact

/api/v1/users and /api/v1/friends and /api/v1/dm

MethodPathWhat it does
GET/users/searchFind a user by name (also used to add server members)
GET/friendsList friendships
POST/friendsSend a friend request
POST/friends/:userId/acceptAccept
DELETE/friends/:userIdRemove / decline
GET/dmList DM channels
POST/dmOpen a DM (friends only)

/api/v1/e2ee

MethodPathWhat it does
POST/devicesRegister this machine's device key
GET/devices/mineList my own devices
DELETE/devices/:deviceIdRevoke a device
GET/backupFetch the sealed identity backup
PUT/backupStore/replace it
GET/devicesList another user's devices (for wrapping a new channel key)
GET/keys/:channelIdFetch wrapped channel keys addressed to me
POST/keysPublish newly-wrapped channel keys

/api/v1/uploads

MethodPathWhat it does
POST/pictureAvatar / server icon (unencrypted, strict image allowlist)
POST/Single-request attachment upload
POST/multipartOpen a multipart session (sealed ticket, no server-side state)
POST/multipart/partUpload one part
POST/multipart/completeFinish and assemble
DELETE/multipartAbort a session
GET/:key(*)Download (always application/octet-stream, session-checked)

Attachments are encrypted client-side before upload and served only as opaque downloads — see E2EE.md.