Edits and edit history
toEditMessageContent and toMessageEdits: the edit request body and the edit-history conversion.
Edits and edit history
Which endpoints the adapter's messaging calls when acting on existing messages (reactions, edits, recalls) and when fetching edit history and the change log, how realtime frames become signals, and two reusable converters. Use the two converters when you write your own host against OpenMax, so you send exactly what the SDK sends. Status and an index of every export are on the Overview.
Message endpoints
| Member | Endpoint | On failure |
|---|---|---|
addReaction, removeReaction |
POST /api/v1/messages/{id}/reactions, DELETE /api/v1/messages/{id}/reactions/{code} |
412 and 403 throw a ChatSdkRequestError with kind forbidden (isChatOperationNotAllowed() recognises it); anything else gets the kind from its status |
editMessage |
PUT /api/v1/messages/{id}, body built by toEditMessageContent |
As above |
recallMessage |
DELETE /api/v1/messages/{id} |
As above |
listMessageEdits |
GET /api/v1/messages/{id}/edits, converted with toMessageEdits |
Throws ChatSdkRequestError |
loadMessage |
GET /api/v1/conversations/{cid}/messages/{mid}, body and attachments taken from content in the detail |
404 and 403 return undefined |
loadChangesSince |
GET /api/v1/conversations/{cid}/changes?since_change_seq=&limit=500, one page per call |
Throws ChatSdkRequestError (including 404: the backend doesn't have the route yet); that catch-up gives up silently |
getMessagesByIds |
POST /api/v1/conversations/{cid}/messages/batch-get { message_ids } |
Throws ChatSdkRequestError; on a network failure, a timeout, 429 or 502–504 (retryable true) the chat backs off 1 second, then 2 seconds, and sends the same batch again, at most 3 sends, then quietly gives up this catch-up; 401 and the like are not retried |
loadReadCursors |
GET /api/v1/conversations/{cid}/read-cursors; member_id, last_read_seq, last_ack_seq, member_count and truncated become the contract fields |
On 412 (read receipts are off for that conversation) and 403, rejects with a ChatSdkRequestError of kind forbidden; never returns an empty snapshot |
On success the four write methods return { changeSeq } (when the response has change_seq); edits also return editedAt (an ISO string).
loadThread and loadThreadSince pass the list response's head_change_seq on as headChangeSeq (left out when the response has none), from which the chat catches up, through the change log, on changes others made to existing messages while you were away.
When loadReadCursors rejects, the message thread treats the conversation as having no read receipts: it draws no receipt and shows no message. An empty snapshot would be drawn as single ticks (nobody has read it), which is why a failed fetch rejects.
Realtime frames
| Frame | Signal |
|---|---|
message, sync |
messages: only the conversation id; the SDK fetches the content |
system message.reaction.added, message.reaction.removed |
reaction: which message, who, which emoji, added or removed |
system message.updated, message.recalled, message.deleted, card.interaction.recorded |
messageChanged, with change edited, recalled, deleted and card; a frame without message_id is dropped |
read_state_update, delivery_state_update |
read, delivery |
A non-negative integer change_seq on the frame (a number or a numeric string) is passed on as changeSeq; frames from older servers have none, and then it is left out. message.updated carries no body and card.interaction.recorded no card fields, so the thread fetches the message again with loadMessage.
toEditMessageContent
function toEditMessageContent(edit: ChatMessageEditInput): OpenMaxEditMessageBody;
The body of the edit request (PUT /api/v1/messages/{id}):
- No attachments left:
content_type: "text",body: { text }, emptyattachments. - Attachments left:
"image"when they are all images, otherwise"file"(a mix of images and files is"file"too);body.file_nameis the first one's name, andtextis included only when non-empty. Attachments are replaced as a whole set, in display order, not reordered. - No
typeorfallback_text: the message'stypeand the preview text in the conversation list keep their values from before the edit.
OpenMaxEditMessageBody
interface OpenMaxEditMessageBody {
content: {
content_type: "text" | "image" | "file";
body: Record<string, unknown>;
attachments: ChatAttachment[];
};
}
What toEditMessageContent returns, used unchanged as the body of the edit request.
toMessageEdits
function toMessageEdits(items: readonly OpenMaxMessageEditItem[] | null | undefined): ChatMessageEdit[];
Turns the items of the edit-history endpoint into ChatMessageEdit, in the original order (oldest first). Milliseconds become an ISO string; when body.text is a string it is used, otherwise the whole body as JSON. items that are null or missing count as an empty list.
OpenMaxMessageEditItem
interface OpenMaxMessageEditItem {
id: string;
created_at: number;
body?: Record<string, unknown> | null;
}
The fields of one edit-history item that toMessageEdits reads: id, the time of the edit created_at (unix milliseconds), and the content of the version before the edit, body.
