Skip to content

Chat ​

Who: listener on a registered device (sessions must be bound to a device); system for offline push and key fan-out.

What goes inside the encrypted envelopes (keys, padding, content JSON, attachments, sender keys, acknowledging) is in Chat content, the canonical client contract.

Entry points ​

KindEntry
REST (keys)PUT /messaging/keys/devices/me, PUT …/devices/me/signed-prekey, POST …/devices/me/prekeys, GET …/devices/me/prekeys/count, GET /messaging/keys/users/:userId/devices, POST /messaging/keys/users/:userId/bundles
REST (chats)GET/PATCH /messaging/settings, GET /messaging/presence, GET /messaging/conversations, GET …/conversations/search, POST …/conversations/direct, POST …/conversations/groups, GET/PATCH …/conversations/:id, PATCH …/:id/state, PUT …/:id/disappearing, POST …/:id/request, members, invites, join requests, POST /messaging/invites/:code/join
REST (messages)POST /messaging/messages, `PATCH/DELETE /messaging/messages/:id?scope=me
Socket /chatmessage:send, message:edit, message:delete, message:delivered, message:seen, message:played, message:react, typing:start, typing:stop, envelope:sync, senderkey:distribute, senderkey:ack, presence:ping, presence:get
Deep linkchat (chat/:id), chatInvite (chat/invite/:code)
Pushmessage.received (no content, collapsed per chat)

Flow ​

  1. Keys: on first sign-in per device PUT /messaging/keys/devices/me (identity key), signed prekey, one-time prekeys. Low stock (< 20) → keys:low → upload more. A new identity key → messaging.keys.identity_changed → messaging.key-change-fanout → keys:changed to everyone sharing a chat.
  2. Start a chat: POST /messaging/conversations/direct { userId }. The recipient's whoCanMessage (everyone, followers, mutuals, nobody) decides: allowed → normal chat; otherwise a message request in their requests folder; nobody → MESSAGING_CHAT_DISABLED. Groups: POST …/groups with roles, invite links and join requests.
  3. Send: fetch bundles POST /messaging/keys/users/:userId/bundles, encrypt per device (sender keys in groups), message:send { conversationId, clientMessageId, kind, envelopes[] }. Event messaging.message.sent; devices online get message:new; offline devices get message.received via messaging.offline-push after a short delay.
  4. Request decision: recipient POST /messaging/conversations/:id/request { accept | decline } → chat:state.requestState; event messaging.request.decided. Declined → sender gets MESSAGING_REQUEST_DECLINED on send.
  5. Receipts: message:delivered, message:seen { upToMessageId }, message:played → message:status to the sender (subject to read-receipt visibility settings). Typing is never stored.
  6. Delete for everyone: message:delete { messageIds, scope: "everyone" } within the window → message:deleted to members, event messaging.message.deleted. scope: "me" only hides it locally.
  7. Catch-up: envelope:sync (or GET /messaging/devices/me/envelopes) then ack. Undelivered envelopes drop after 30 days (messaging.maintenance).
  1. A group always has a name. It is required on create (1–100 characters, trimmed), and the database enforces it. Renaming follows the "only admins edit info" setting and posts a title_changed item.
  2. Each group has one primary link (GET …/invites/primary).
    • Rotate gives it a new code; the old code stops working immediately.
    • Reset revokes every link and returns a fresh primary.
    • Admins can also make extra links with an expiry, a use limit and their own approval setting.
  3. Tapping https://spread.plemuz.com/chat/invite/<code> (links.chatInvite) opens the guest-safe preview: name, avatar, member count and whether approval is needed, but no member list.
  4. Joining needs sign-in; a guest is sent to sign in with a deep link back to the invite. The result is joined, or a join request when approval applies.
  5. A revoked, expired or used-up link gets a calm error that suggests asking an admin for a new link.

Exit states ​

StateCodeActionsClient next
Delivered——Show ticks from message:status
Device not boundMESSAGING_DEVICE_REQUIREDsign_inSign in again on this device
Recipient has no keysMESSAGING_DEVICE_KEYS_MISSINGupdate_app—
Device list changedMESSAGING_DEVICE_MISMATCHretryRefetch bundles, re-encrypt
Sender key missingMESSAGING_SENDER_KEY_MISSING—Distribute, resend
Blocked / disabled / declinedMESSAGING_BLOCKED, MESSAGING_CHAT_DISABLED, MESSAGING_REQUEST_DECLINED—Show the title
Not allowed to addMESSAGING_ADD_NOT_ALLOWED——
WindowsMESSAGING_EDIT_WINDOW_CLOSED, MESSAGING_DELETE_WINDOW_CLOSED—Offer delete for me
LimitsMESSAGING_MEMBER_LIMIT, MESSAGING_PIN_LIMIT, MESSAGING_FORWARD_LIMIT, MESSAGING_PREKEY_LIMIT——
InviteMESSAGING_INVITE_INVALID, MESSAGING_INVITE_EXPIRED, MESSAGING_JOIN_REQUEST_PENDING (wait)as listed—

Notifications ​

message.received only. Requests and their decisions send nothing.

Known gaps ​

  • No deep-link screen for the message-requests folder (M7).
  • Messaging has no block command from identity and no moment-reply text yet (STATUS); blocks are read, not pushed.
  • Device keys, prekeys and envelopes survive account erasure (B3).

Plemuz API v2