Repository navigation
Conversation
Adds the route, its delegated OAuth scope (fmsg:read) and the response shapes for an optional thread search, documented in the README, so clients can rely on one contract. This server does not implement it and answers 501 Not Implemented to an authenticated caller. Before, the path fell through to GET /fmsg/:id and answered 400 "invalid message id". A q with no words (only punctuation) is specified to answer 200 with no threads, which gives clients a cheap way to tell whether a server implements search. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
markmnl
left a comment
There was a problem hiding this comment.
Looks good. I checked the contract against a working implementation of this endpoint. The parameters, defaults, 400/503 answers and response fields all match, so clients written to this README will work against it. One fix and a few clarifications:
1. Client guidance should include 400 (fix). The README tells clients to treat `501` "(or `404` from older servers)" as "search is not available". But as this PR's own description says, servers before this change route `/fmsg/search` to `GET /fmsg/:id` and answer 400 "invalid message id", not 404. Suggest: "Clients should treat `501`, or `400`/`404` from servers that predate this endpoint, as search not being available." (markmnl/fmsg-mcp#39 already treats 400 that way in its probe.)
2. Document the probe. The "`q` with no words answers `200`" rule is the cheap support check. It's worth saying so outright, with the exact request, e.g. "To check whether a server implements search, request `GET /fmsg/search?q=-&limit=1`: 200 means yes." Then clients don't each invent a different probe.
3. Smaller clarifications:
- `messages`: it says reactions are left out. Are FMSG-008 edit messages left out too? The fmsg-mcp client filters them out itself, which suggests they might appear. Worth stating either way.
- `limit`: "at most 50": is a larger value clamped to 50, or a 400? The implementation I checked clamps.
- `match.field: to`: does it include recipients added later (add-to)?
- `trash=exclude`: `messages` includes trashed messages "so the thread can be grouped". Say explicitly that clients should leave them out of counts and previews unless `trash=only`. Otherwise unread counts include deleted messages (see my comment on fmsg-mcp#39).
4. Nits, no change needed:
- `searchMatch`/`searchThread`/`searchResponse` are unused in this server. `go vet` is fine with that, but staticcheck's U1000 would flag them if it's ever added. A one-line `var _ = searchResponse{}`, or a comment that they're the contract, would keep it quiet.
- The handler-level 401 is redundant behind the JWT middleware in production, but it keeps the route test meaningful. Fine as is.
- Clients treat 501, or 400/404 from servers predating the endpoint, as no search; document the q=- probe. - limit above 50 is treated as 50; match field to includes added recipients. - messages include edit and trashed messages for grouping; clients leave them out of counts unless trash=only. - Keep the contract types referenced so unused-code checks stay quiet. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Defines
GET /fmsg/searchas an optional endpoint: the route, its delegated OAuth scope and the response shapes, documented in the README, so that clients can rely on one contract. This server doesn't implement search: it answers501 Not Implementedto a signed-in caller and401otherwise. A deployment that indexes message text can implement it.Before this change,
/fmsg/searchfell through toGET /fmsg/:idand answered 400 "invalid message id".Changes
cmd/fmsg-webapi/main.go:fmsg.GET("/search", msgHandler.Search), registered before/:id.internal/middleware/oauth.go:GET /fmsg/searchrequiresfmsg:read.internal/handlers/search.go: the contract types and aSearchhandler that answers 501.GET /fmsg/searchsection. It covers:q,sort,files,unread,scope,trash,limit,offset;total,next_offset,terms,threadswithmatch, andmessages;qout of logs.qwith no words (only punctuation) answers200with no threads. That gives clients a cheap way to tell whether a server implements search: 200 means yes, 501/404 means no.Testing
cmd/fmsg-webapi/search_route_test.go: 501 when signed in, 401 when not, and the request reaches the search handler rather thanGET /fmsg/:id.go vet ./...andgo test ./...pass.🤖 Generated with Claude Code