Commit graph parsimony/internal/api
Author SHA1 Message Date
tgiachi
34f461bb6b Merge branch 'feat/nl-posts-stats' into feat/newsletter 2026-11-10 13:02:41 +01:00
tgiachi
2f2ee71f92 feat(api): list the posts of a list with their delivery counters
- GET /api/v1/lists/{id}/posts?limit= returns id, message_id, subject,
  created_at, recipients, sent, failed, dropped and pending, newest
  first; 404 for an unknown list, 400 for a bad limit, token required
- discarding a queued delivery counts it as dropped (store.DropOutbox)
- openapi: the new path and the discard note
2026-11-10 12:40:55 +01:00
tgiachi
0bbfd43e30 feat(api): publisher flag on members and the publishers post policy
- the member DTO carries publisher
- POST /lists/{id}/members takes an optional publisher: absent leaves the flag
  of an existing member alone, true or false sets it
- PATCH /lists/{id}/members/{address} with {"publisher": bool}: 404 for a
  non-member, 400 when the field is missing
- the list PATCH accepts post_policy publishers; the validation message says so
- openapi updated
2026-11-10 12:38:35 +01:00
tgiachi
b2f447f875 Merge branch 'fix/input-validation' into fix/fable-mediums 2026-11-10 12:01:07 +01:00
tgiachi
f7ce18c3d4 test: close the gaps found by mutation checks
- api: empty names, '{' in a name, 253/254-character domains, title trimming and the name fallback
- config: an empty query or fragment in base_url
- router: leaving works on a list closed to new members
- store: an expired token is removed when presented
2026-11-10 11:57:49 +01:00
tgiachi
38552f8025 fix(app): add read, write and idle timeouts to the HTTP servers
- the API + admin UI server and the public web server get ReadTimeout 30s,
  WriteTimeout 60s and IdleTimeout 120s next to ReadHeaderTimeout
- the archive import extends its own read and write deadlines to 30
  minutes with http.ResponseController, so a big mbox is not cut
- tests: a stalled body and an idle connection are cut on both servers,
  an import longer than the default timeouts succeeds, fields are pinned
- README: document the limits and timeouts
2026-11-10 11:54:50 +01:00
tgiachi
b8fcbf9acf fix(api): validate list name, domain and title on create
createList accepted a title with CR/LF (every later post to the list then
failed to rewrite and got 451) and names with '/', '<', '>' or tabs.

- name: lowercased, 1 to 30 characters of a-z 0-9 . _ -, no leading or trailing dot, no ".."
- domain: lowercased ASCII host name, labels of 1 to 63 characters
- title: non-empty single line, at most 200 characters, no control characters
- updateList uses the same title rule (it also refuses tabs and long titles now)
- tests: refused names, domains and titles, the accepted limits, nothing created for a bad title
2026-11-10 11:50:40 +01:00
tgiachi
28b73fa24a test(api): every route but health answers 401 without the token
routes() is now the single table New registers, so a route added later is
covered by TestEveryRouteNeedsTheToken without editing it.

- api: declare the routes in one table (routes) and register from it
- api: table test walks it, 401 without a token, not 401 with one
2026-11-10 11:49:32 +01:00
tgiachi
94b5a58e93 fix(store): moderation listings never read message bodies, bound the held bytes
- Store subject, From header and size when a message is held; ListHeld returns the summary only
- Cap one held message at 10 MiB (ErrHeldTooLarge) and the bytes held per list at 200 MiB (ErrHeldFull)
- Summarise the messages already held when migrating an existing database, one at a time
- Show the From header and whether it differs from the envelope sender in the held API
- Thread listings no longer load the bodies of the thread
2026-11-10 11:39:21 +01:00
tgiachi
7005edcb9b test: pin the documented limits and close gaps found by mutation checks
- Test the lockout, the confirmation cap and Retry-After with literal numbers, not the constants
- Test that failed deliveries are listed before the most retried ones
2026-11-09 20:43:41 +01:00
tgiachi
afd067688c feat: show failed deliveries in the API, CLI and UI 2026-11-09 20:34:37 +01:00
tgiachi
625d487eca fix(security): API token strength and brute-force lockout
- Refuse an API token under 24 characters or with whitespace at startup, without echoing it
- Lock an address out for 5 minutes after 10 wrong or missing tokens in 5 minutes (429 with Retry-After)
- Ignore X-Forwarded-For for the lockout, forget idle addresses
- Document both
2026-11-09 20:25:05 +01:00
tgiachi
eb9e915805 fix(security): hold posts whose From header does not match the sender
- Judge membership on the envelope sender and require the From header to name the same address
- Hold mismatches (and missing, unparsable or multiple From addresses) for the admin instead of delivering
- Record why a message was held: new held.reason column, migrated, shown in the API, CLI and UI
- Accept an empty message in the held queue
- Document who may post
2026-11-09 20:23:07 +01:00
tgiachi
a170204ecb test: close gaps found by mutation checks on the archive import
- Cover the CRLF separator line, cycle roots entered from outside, linear rethreading of long chains
- Cover a read error mid-import, the "and N more" lines, and the mbox content type
- Cover clearing the previous result and the capped error list in the UI
2026-11-09 19:50:40 +01:00
tgiachi
cd596e1810 feat(api): import an mbox into a list's archive
- Add POST /api/v1/lists/{id}/archive/import, streaming the body
- Return a summary of imported, duplicate and failed messages; failures do not fail the request
- Import regardless of the archive policy
2026-11-09 17:15:05 +01:00
tgiachi
6461e77a95 feat: document the queue, close mutation gaps, plain relay errors
- Document delivery semantics, retries and the queue API in the README and OpenAPI
- Add relay.concurrency to the example config
- Test that a relay problem never counts against a member, that the longest-waiting delivery goes first, and the error and limit details
- Show the plain relay error when there is a single batch
2026-11-09 16:04:45 +01:00
tgiachi
98bbcf6b68 feat(api): inspect and discard the outbound queue
- Add GET /api/v1/queue with totals, oldest age and up to 100 deliveries, failing ones first
- Add DELETE /api/v1/queue/{id} to discard a stuck delivery
- Never expose message contents
2026-11-09 15:54:13 +01:00
tgiachi
8f64ac671d feat: serve the public web from the daemon and document the archive
- Add web.listen config (default 127.0.0.1:8081, empty disables)
- Start the public web in app, close it with the rest
- Add end-to-end test: archive stays private, becomes public, hides addresses, one-click unsubscribe works
- Cover mutation survivors: attachments, first text part, multibyte cap, member id 0, page clamp, API limit cap, closing connections
- Update OpenAPI, README and example config
2026-11-09 15:22:50 +01:00
tgiachi
d8275aaa1f feat(store,api): archive with full-text search, threading and archive policy
- Add archive table with FTS5 index kept in sync by triggers
- Deduplicate by Message-ID per list so MTA retries do not repeat posts
- Thread messages through In-Reply-To within the same list
- Quote every search word so user input is never FTS syntax
- Add archive_policy (public, private, off) with migration
- Add API to list, search, read and delete archived messages
2026-11-09 15:17:13 +01:00
tgiachi
ad58789630 feat(api): list policies, held queue and member bounce state
- Add post_policy and join_policy to lists, patchable per field
- Add held message listing, approve and discard endpoints
- Expose disabled and bounce_count on members
- Reject '+' in list names, it is the command separator
- Wire the router release into the daemon
- Update OpenAPI description and README
2026-11-09 15:05:11 +01:00
tgiachi
7ce6a1c98e feat(api): REST API for lists and members
- Add /api/v1 JSON endpoints: lists CRUD, members add/list/remove, health
- Protect routes with a constant-time bearer token check
- Reject unknown JSON fields and invalid names or addresses
- Map store errors to 404 and 409
2026-11-09 14:57:43 +01:00