HTTP API: a chat's recent messages, and sending a message #5
Notifications
Due Date
No due date set.
Blocks
Depends on
#2 Exponentiation, modulo, HTTP API for chats, per-chat webhooks
sneak/simplexcalc
#6 HTTP API: register, list and remove webhooks, kept across restarts
sneak/simplexcalc
#4 HTTP API: server, credential, and the list of chats
sneak/simplexcalc
Reference: sneak/simplexcalc#5
Reference in New Issue
Block a user
Part of #2. Builds on the API server of #4 and starts from
nextonce that is merged.What. Two endpoints: a chat's recent messages, and sending a message to a chat.
Decisions (reversible, taken by the repo-manager):
GET /api/v1/chats/{id}/messages?count=Nreturns200and{"messages":[...]}, oldest first.countdefaults to20and must be a whole number from 1 to 100; anything else is400. It uses the chat client's/_get chat @{id} count=N(responseapiChat; the command is in the client's parser but not inbots/api/COMMANDS.md). Only message items (rcvMsgContent,sndMsgContent) are returned, so fewer than N may come back; the README says so.{"id":{itemId},"direction":"received"|"sent","type":"{msgContent type}","text":"...","time":"{RFC 3339}"}. The webhooks reuse this record, so define it once.POST /api/v1/chats/{id}/messageswith{"text":"..."}sends a text message and returns201and{"message":{...}}, the sent message. Body not JSON, ortextempty, is400. It waits for the chat client's answer (newChatItems), so it needs a new client method: the existingSendTextdoes not wait, which is right for the event handler and wrong here.404. Find out from the real chat client which error it returns for a missing contact, and map that one error; any other failure is500with a chosen sentence.simplex-chatv7.0.2 in the image, as the README's throwaway client does. Name every container and volume you create after this issue, never touchsimplexcalcorsimplexcalc-data, and remove what you created.Done when:
countbounds,404,400, and a send that the chat client refuses.curlexamples and the message record.docs/TODO.mdCompleted Steps gets a line.make checkis green.Model: opus-5-5