Page history by message id (closes #125) #136

Merged
clawbot merged 1 commits from issue-125-history-paging into next 2026-10-20 11:58:40 +02:00
Collaborator

Closes #125.

GET /api/v1/history paged with before set to a database id, which no response gives a client. before now takes the message id the history responses already carry: the server finds that message among those sent to target and returns the page of messages older than it. To page back, a client passes the id of the oldest message on the page it has. An id with no such message gets 400 unknown before id instead of a silent full page. No internal id appears in any response.

The lookup lives in GetHistory in internal/db, which now takes the id; the handler spots an unknown one by sql.ErrNoRows, as the service package does for nick lookups.

A handler test pages back through five messages two at a time using only ids from earlier pages, and checks that every message comes back once, in order. A second test checks the 400 for a made-up id and for the id of a message in another channel. README.md's history section describes the new parameter and error.

Things the diff does not show:

  • Judgement call: the before message must have been sent to target itself, so the id of a message in another channel or DM is unknown there and gets the 400.
  • Judgement call: 400 rather than 404, so the error cannot be mistaken for 404 channel not found.
  • A numeric before such as 0 is now an unknown id and gets the 400.

Model: opus-5-5

Closes https://git.eeqj.de/sneak/neoirc/issues/125. `GET /api/v1/history` paged with `before` set to a database id, which no response gives a client. `before` now takes the message `id` the history responses already carry: the server finds that message among those sent to `target` and returns the page of messages older than it. To page back, a client passes the `id` of the oldest message on the page it has. An `id` with no such message gets `400` `unknown before id` instead of a silent full page. No internal id appears in any response. The lookup lives in `GetHistory` in `internal/db`, which now takes the `id`; the handler spots an unknown one by `sql.ErrNoRows`, as the service package does for nick lookups. A handler test pages back through five messages two at a time using only ids from earlier pages, and checks that every message comes back once, in order. A second test checks the `400` for a made-up `id` and for the `id` of a message in another channel. `README.md`'s history section describes the new parameter and error. Things the diff does not show: - Judgement call: the `before` message must have been sent to `target` itself, so the `id` of a message in another channel or DM is unknown there and gets the `400`. - Judgement call: `400` rather than `404`, so the error cannot be mistaken for `404` `channel not found`. - A numeric `before` such as `0` is now an unknown `id` and gets the `400`. Model: opus-5-5
clawbot added the needs-review label 2026-10-20 11:44:31 +02:00
clawbot self-assigned this 2026-10-20 11:44:31 +02:00
clawbot added 1 commit 2026-10-20 11:44:31 +02:00
Page history by message id (closes #125)
check / check (push) Waiting to run
e59406fb43
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
Author
Collaborator

PASS: meets every item of #125, with before taking the message id the responses carry, each message returned once across page boundaries, an id from another channel or conversation treated as unknown (400), and README.md matching the code.

Model: opus-5-5

PASS: meets every item of https://git.eeqj.de/sneak/neoirc/issues/125, with `before` taking the message `id` the responses carry, each message returned once across page boundaries, an `id` from another channel or conversation treated as unknown (`400`), and `README.md` matching the code. Model: opus-5-5
clawbot merged commit 1019419b17 into next 2026-10-20 11:58:40 +02:00
clawbot deleted branch issue-125-history-paging 2026-10-20 11:58:41 +02:00
Sign in to join this conversation.