Page history by message id (closes #125)
check / check (push) Waiting to run

GET /api/v1/history took a database id for before, but history
responses carry only each message's id, so a client had nothing to
pass for the next page. before now takes that id: the server finds
the message among those sent to the target and returns the page
older than it. An id with no such message gets 400 "unknown before
id" instead of a silent full page. A handler test pages back through
a channel using only ids from earlier responses, and README.md's
history section describes the new parameter.

Model: opus-5-5
Co-authored-by: clawbot <sneak+clawbot@sneak.cloud>
This commit was merged in pull request #136.
This commit is contained in:
2026-10-20 11:58:39 +02:00
committed by clawbot
parent 7c6f0bc01e
commit 1019419b17
5 changed files with 205 additions and 17 deletions
+12 -8
View File
@@ -1836,14 +1836,18 @@ Fetch historical messages for a channel. Returns messages in chronological order
**Query Parameters:**
| Param | Type | Default | Description |
| -------- | ------- | ---------- | -------------------------------------------------------------------------------- |
| `target` | string | (required) | Channel name (e.g., `#general`) |
| `before` | integer | `0` | Return only messages with DB ID < this value (for pagination). `0` means latest. |
| `limit` | integer | `50` | Maximum messages to return, 1–500; any other value gives 50. |
| Param | Type | Default | Description |
| -------- | ------- | ---------- | ------------------------------------------------------------------------------------------------ |
| `target` | string | (required) | Channel name (e.g., `#general`) |
| `before` | string | (none) | The `id` of a message sent to `target`; return only messages older than it. Omit for the latest. |
| `limit` | integer | `50` | Maximum messages to return, 1–500; any other value gives 50. |
To page back, pass the `id` of the first (oldest) message of a page as `before`
for the next; an empty page means there is nothing older.
`target` may also be your own nick, which returns the DMs sent to you. Errors:
`400` `target required`, `404` `channel not found`, `403`
`400` `target required`, `400` `unknown before id` when no message with that
`id` was sent to `target`, `404` `channel not found`, `403`
`not a member of this channel`, and `403` `forbidden` for any other nick.
**Response:** `200 OK`
@@ -1881,8 +1885,8 @@ events). Event messages are delivered via the live queue only.
curl -s "http://localhost:8080/api/v1/history?target=%23general&limit=50" \
-b cookies.txt | jq .
# Older messages (pagination)
curl -s "http://localhost:8080/api/v1/history?target=%23general&before=100&limit=50" \
# The 50 messages before uuid-1 (pagination)
curl -s "http://localhost:8080/api/v1/history?target=%23general&before=uuid-1&limit=50" \
-b cookies.txt | jq .
```