feat: add message reliability foundation
All checks were successful
CI / test (push) Successful in 23s
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:
@@ -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
|
||||
});
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user