feat: add message reliability foundation
All checks were successful
CI / test (push) Successful in 23s

- implement idempotent message creation via client_message_id

- add persistent delivered/read receipts

- expose /messages/status and wire websocket receipt events

- update web client to send client ids and auto-ack delivered/read
This commit is contained in:
2026-03-07 23:57:35 +03:00
parent ff6f409c5a
commit f6ad480973
13 changed files with 382 additions and 28 deletions

View File

@@ -35,6 +35,21 @@ export async function sendMessage(chatId: number, text: string, type: MessageTyp
return data;
}
export async function sendMessageWithClientId(
chatId: number,
text: string,
type: MessageType,
clientMessageId: string
): Promise<Message> {
const { data } = await http.post<Message>("/messages", {
chat_id: chatId,
text,
type,
client_message_id: clientMessageId
});
return data;
}
export interface UploadUrlResponse {
upload_url: string;
file_url: string;
@@ -77,3 +92,15 @@ export async function attachFile(messageId: number, fileUrl: string, fileType: s
file_size: fileSize
});
}
export async function updateMessageStatus(
chatId: number,
messageId: number,
status: "message_delivered" | "message_read"
): Promise<void> {
await http.post("/messages/status", {
chat_id: chatId,
message_id: messageId,
status
});
}