HTTP API: a chat's recent messages, and sending a message #15

Merged
clawbot merged 4 commits from issue-5-chat-messages into next 2026-09-29 07:33:37 +02:00
4 Commits
Author SHA1 Message Date
clawbot 513d2a5353 README: state the rule for a query that cannot be read (closes #5)
check / check (push) Successful in 1m9s
The README listed the queries that GET /api/v1/chats/{id}/messages
cannot read as if the list were complete, but a query of more than
10,000 parts separated by & is refused the same way, because Go's
url.ParseQuery takes no more. The README now states the rule, that a
query the server cannot read gets 400 with "the query cannot be read",
and gives the three cases as examples. TestMessagesUnreadableQuery
covers the 10,000-part case.

Model: opus-5-5
2026-09-29 05:17:01 +00:00
clawbot 4824937c92 HTTP API: its own 400 for a query that cannot be read (closes #5)
check / check (push) Successful in 1m12s
GET /api/v1/chats/{id}/messages answered any query that does not
decode, such as one holding ; or %zz, with the sentence about count,
even when count was valid or absent. It now answers such a query with
"the query cannot be read", and keeps the count sentence for a count
that decodes but is not a whole number from 1 to 100. The README names
both cases.

Model: opus-5-5
2026-09-29 05:08:52 +00:00
clawbot 2ce8da766a HTTP API: 404 for a chat id the list of chats leaves out (closes #5)
check / check (push) Successful in 1m19s
The chat client keeps contact records that GET /api/v1/chats does not
list, such as the bot's own profile (1 on a new profile) and a contact
it creates itself (2), and reads or sends in them when asked. The
message endpoints now look the id up, through chatID in
internal/api/chats.go, in the same list the chats endpoint answers
with, and answer 404 for any id not in it. The webhook endpoints can
call chatID too.

Model: opus-5-5
2026-09-29 04:32:28 +00:00
clawbot 2ad0b68e35 HTTP API: a chat's recent messages, and sending a message (closes #5)
check / check (push) Successful in 1m21s
GET /api/v1/chats/{id}/messages returns the messages among a chat's
last count items (default 20, at most 100), oldest first. POST sends a
text, waits for the chat client's answer and returns 201 with the
message as sent. A chat the bot does not have is 404, a contact who
deleted the chat is 409, a text too long for one message is 413, and
any other failure is 500 with a chosen sentence.

The chat client spells out a message's formatting in its answer, up to
26 times the text's length, so 100 items in one answer can pass the
16 MiB read limit and end the connection. Items are read five at a
time.

Model: opus-5-5
2026-09-29 03:48:45 +00:00