HTTP API: 404 for a chat id the list of chats leaves out (closes #5)
check / check (push) Successful in 1m19s
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
This commit is contained in:
@@ -180,7 +180,7 @@ A message has:
|
||||
it.
|
||||
|
||||
A `count` other than a whole number from 1 to 100 gets `400`, and an
|
||||
`id` that is not one of the bot's chats gets `404`.
|
||||
`id` that `GET /api/v1/chats` does not list gets `404`.
|
||||
|
||||
### `POST /api/v1/chats/{id}/messages`
|
||||
|
||||
@@ -208,7 +208,7 @@ curl -H "Authorization: Bearer $TOKEN" -H 'Content-Type: application/json' \
|
||||
Nothing is sent, and the answer is:
|
||||
|
||||
- `400` if the body is not JSON of that shape, or `text` is empty;
|
||||
- `404` if `id` is not one of the bot's chats;
|
||||
- `404` if `GET /api/v1/chats` does not list `id`;
|
||||
- `409` if the contact cannot receive messages: they have deleted their
|
||||
chat with the bot (`contact_deleted` is `true`), or have not finished
|
||||
connecting;
|
||||
|
||||
Reference in New Issue
Block a user