Repository navigation
List my claimed repeaters on My account - #2430
Conversation
A user could claim repeaters but had no page listing them: the claims
only showed on each node page, in the admin user detail and in the data
export.
GET /api/account/repeaters returns the caller's claims, each with the
node name, whether it is still in the analyzer database, when it was
last heard (the newer of its last advert and the last transmission
certainly from it, as on the node page), when its prefix last relayed,
the saved status and the other active maintainers.
My account gets a My repeaters section after Companions. It shows silent
repeaters first, using getNodeStatus with the same repeater threshold as
the node pages, then the saved status, the claim date, the
co-maintainers and an Unclaim button (with a confirm) that uses the
existing DELETE /api/repeaters/{pubkey}/claim. A repeater that left the
database stays listed until it is unclaimed. #/account?section=repeaters
links straight to it.
The route takes a browser session only; device tokens answer 403.
|
Thanks for this. Auth is right: the list is keyed on the session user only, anonymous gets 401 and a device token 403, disabled co-maintainers are hidden and no email leaves the server. Named structs, no new users.db or analyzer DB writes, one bulk fetch, escaping and the Two things before merge:
Not blocking:
Not checked: the Playwright E2E and the network-call lint (it did not resolve from my temp worktree), and no browser check. |
Review follow-up for My repeaters. A repeater silent longer than retention.nodeDays moves from nodes to inactive_nodes, so it showed as no longer in the database after about four days of being silent, which is the case the list is for. Claimed pubkeys missing from nodes are now read from inactive_nodes (name, role, last advert) and marked inactive; known: false is left for a node in neither table. The saved status and co-maintainers now come from two queries for all of the user's claims instead of two per claim. account.js takes getNodeStatus and timeAgo as parameters, so the unit test runs the real roles.js and asserts the uncertain row (chip class, text, sort position); the 72 h fallback is gone. A Go test drives the handler with a packet store holding a certain-heard entry newer than the advert and a relay entry. Unclaim and Unlink are disabled while their DELETE runs, so a double click no longer shows a 404 over the success message.
|
Thanks for the thorough review. All four points are addressed in c8d6afe:
Locally: |
|
Nice work on this, and on the quick turnaround of the first review. I read A few suggestions, each with what I'd change:
Nit, take it or leave it: |
|
Apologies for point 4 of my review: I got it wrong. I assumed |
Second review follow-up for My repeaters.
Inactive and unknown rows showed the name as a link to #/nodes/{pubkey},
but /api/nodes/{pubkey} reads only nodes, so the node page said Node not
found. Those rows now show the name as plain text.
An inactive row read the same as one silent for a few days. Its chip now
ends in "no longer in the node list".
The E2E dismiss step waited a fixed 300 ms. It now records claim DELETE
requests and checks that none was sent and the claim is still listed.
InactiveNodeBasics moves to repeater_lookup.go, next to RepeaterKnown.
|
Thanks, all three points and the nit are in 5fa7deb:
|
|
Re-review at
Locally: Merging. Two small things for a follow-up, neither blocks:
|
GET /api/account/repeaters (My repeaters, from Kpa-clawbot#2430) now also takes a device token with repeater:claim or repeater:edit; an rx-only token still answers 403. An app cannot build this list from the public catalog: claimers there are display names, and a claimed repeater that left the node list is missing from it. Reading one repeater at a time would take a request per repeater and miss those as well.
…#2440) Follow-up to #2430, covering the two points from @efiten's re-review. - **Unclaim and Unlink stay disabled until the list reloads.** Both click handlers now return the list reload from the DELETE's `.then` (`public/account.js`), so the button is re-enabled only after the redrawn list has replaced it. Before, a click between the DELETE's answer and the list GET's answer sent a second DELETE. - **The dropped-from-node-list note shows in every state.** `repeaterHealth` adds "no longer in the node list" whenever `r.inactive` is set, so an inactive repeater that was heard recently or whose prefix still relays is marked too, not only a silent one. Tests (`tests/unit/test-user-management-ui.js`, 103/103): - For both Unclaim and Unlink, the button stays disabled while the list GET after the DELETE is pending, and a click in that window sends no second DELETE. - An inactive repeater carries the note when active, uncertain, stale and never heard, and none of those rows links to a node page. `tests/e2e/test-lint-network-calls.js` 47/47. Co-authored-by: Adam <196335+anieto@users.noreply.github.com>
Draft for feedback: a working version of native repeater claims and edits from mobile clients, built on the repeater info feature from #2415. Four open questions are at the end. ## Situation Repeater info (#2415) can only be claimed and edited from a browser session. Device tokens from `POST /api/auth/device-token` are limited to `rx` (CoreDrive RX: settings and companion linking), and `GET /api/repeaters/{pubkey}/info` treats a bearer token as anonymous. A mobile client can show a repeater's details but can't offer "claim" or "edit" natively. `PUT /api/repeaters/{pubkey}/info` is also a full replace with no precondition. Two people editing from the same copy silently overwrite each other. That's rare in the browser, but likelier from an app that keeps a cached copy. ## Change Three commits, one per piece. **1. Device-token scopes for the repeater routes** (`8aba3715`) - `POST /api/auth/device-token` takes an optional `scopes` list. Omitted (or `null`) still means `["rx"]`, so CoreDrive RX and every existing token keep exactly their current permissions. An empty list or an unknown scope answers 400, checked before the password. - New scopes: - `repeater:claim`: `POST` and `DELETE /api/repeaters/{pubkey}/claim`. These already only add or remove the caller's own claim. Several claimers per repeater, idempotent `POST`, unchanged. - `repeater:edit`: `PUT /api/repeaters/{pubkey}/info`, still subject to `CanEditRepeater`. - Every device token may use `/api/auth/me` and `/api/auth/logout`, so a repeater-only token can check and end its own login. - `GET /api/repeaters/{pubkey}/info` with a token holding either repeater scope returns `canEdit` and `claimedByMe`. An unknown or expired token answers 401 rather than passing as anonymous, so a client learns its login is gone. A valid token without a repeater scope still gets the public view. A cookie still wins over a bearer header, as elsewhere. - `GET /api/account/repeaters` (My repeaters, from #2430) also takes a token holding either repeater scope, so an app gets the account's claims in one request. It can't build that list from the public catalog, where claimers are display names, and reading repeaters one at a time would miss a claimed repeater that has left the node list. An `rx`-only token still answers 403. - Scope checks are method-aware (`bearerScopesFor(method, path)`). The repeater paths are added to the bearer CORS paths. - Same handlers, validation, rate limit (`repeater`, 120/h per user and per IP), audit actions and admin claim removal as the browser. Token writes add `via: device` to the `repeater.claim`, `repeater.edit` and `repeater.unclaim` rows, and the `user.login` row records the granted scopes. The admin route keeps refusing bearer tokens. **2. Conditional edits with a revision** (`9f9bf47b`) - `users.db` schema v10 adds `repeater_info.revision`. Existing rows start at 1; a repeater with no saved details is at 0. Claims don't change it. - `GET` (single and list) and `PUT` responses include `revision`. - `PUT` accepts an optional `baseRevision`. The check is part of the write statement, so of two saves from the same base exactly one lands: - `baseRevision: 0` (first save): `INSERT … ON CONFLICT(pubkey) DO NOTHING`. - `baseRevision: n`: `UPDATE … SET revision = revision + 1 … WHERE pubkey = ? AND revision = ?`. - No match answers `409` with the stored details (`canEdit`/`claimedByMe` included) and writes nothing. That's the same shape `PUT /api/account/settings` uses for its conflicts. - A stale base is refused even when the body would change nothing. - Permission is checked first, so a 409 never shows details to someone who can't edit. - Without `baseRevision` the save is unconditional and bumps the revision, so `public/repeater-info.js` works unchanged. - `/api/config/client` adds `userManagement.repeaterTokens: true`, so a client can tell this server from one without the scopes or `baseRevision` (older servers answer the device-token request with the SPA page, as noted for `companionLinking`). **Discovery and conflict recovery, for a client:** 1. Check `userManagement.repeaterTokens` in `/api/config/client`. Without it, keep the claim and edit actions hidden. 2. Log in with `scopes: ["repeater:claim", "repeater:edit"]` (or just what the client offers). The response echoes the granted `scopes`. 3. Read `GET /api/repeaters/{pubkey}/info` with the token. Show Claim/Unclaim from `claimedByMe` and Edit from `canEdit`, and keep `revision`. 4. Save with `PUT …/info` and `baseRevision` set to that revision. On 200, keep the new `revision` from the response. On 409, the body is the current record: show or merge it, then retry with its `revision`. On 401, log in again. On 403, the account can no longer edit (for example someone claimed it), so refresh from `canEdit`. **3. Account page device list** (`d28374aa`) My account, Devices labelled every device token "CoreDrive RX". `/api/account/sessions` now includes a device token's `scopes`. The page keeps the CoreDrive RX label for `rx` tokens (and rows without scopes). It shows other tokens under the device name the app sent, with a line such as "can claim repeaters and edit repeater details". Docs: `openapi.go`, `docs/api-spec.md` and the Repeater info section of `docs/user-guide/accounts.md`. ## Questions 1. **One scope or two?** This uses separate `repeater:claim` and `repeater:edit`, so a client can ask for less, and a token that only edits can't put the user's name on a repeater publicly. One `repeater` scope would be simpler if you'd rather not split it. 2. **Editing unclaimed repeaters from mobile.** This keeps web parity: any active user may edit a repeater nobody has claimed, and once it has claimers only they (and admins) can. The alternative is to require a claim before a token may edit. That's stricter, but then app and browser rules differ. 3. **Operator switch.** There's no new setting: the scopes are available whenever `userManagement` is on, and the user opts in when the app asks for them at login. Would you want an explicit opt-in such as `userManagement.mobileRepeaterWrites`? 4. **Stale-edit contract.** Does `revision` plus `baseRevision` in the body, with 409 returning the current record, fit? I matched account settings rather than `ETag`/`If-Match`, to keep one pattern in the API. The browser editor doesn't send `baseRevision` yet. Making it send one would be a small follow-up, if you want browser saves protected too. ## Tests - `cmd/server/repeater_device_token_test.go`: - default and requested scopes, rejected scopes, and the method-aware route table; - per-scope allowed and denied routes, logout with a repeater-only token; - claim and unclaim of own claim only, alongside another claimer; - edit permission (unclaimed repeater, claimer, non-claimer, admin) and a disabled account; - the admin route refusing tokens; - authenticated, public and expired-token reads; - `via: device` audit rows, cookie writes still needing CSRF, and session scopes. - My repeaters with a claim or edit token (own claims only), and 403 for an `rx`-only token. - `cmd/server/repeater_revision_test.go`: - revision on reads, a first edit with no saved row, and a stale base returning 409 with the current record and no audit row; - unconditional browser saves, validation and permission order; - two concurrent saves from the same revision (one 200, one 409), and the client config flag. - `internal/users/repeater_revision_test.go`: - revision counting and conditional first and later saves; - an 8-way race for both cases (`-race`); - the v9 to v10 upgrade. - `tests/unit/test-user-management-ui.js`: app token labels and scope line. Run locally: - `make test`: all 16 modules OK. - `sh test-all.sh`: all suites pass, run in `node:24-bookworm`. On macOS, `test-manage-workflow.js` fails 2 cases on unchanged master because of the BSD tools. - `npx eslint public/*.js`: 0 errors, the same 87 warnings as master. - `node tests/e2e/test-lint-network-calls.js` - `tests/e2e/test-user-management-e2e.js` against local e2etest servers with the CI config: 44/44. - Manually against a local instance: - in the browser: claim, edit, unclaim, and the Devices list; - with curl: the token flow, including a 409 after a browser save. Not run: the full Playwright shard matrix from CI. --------- Co-authored-by: Adam <196335+anieto@users.noreply.github.com>
… scope comments (#2450) Two follow-ups from the #2429 review, split out of #2447 so they don't wait on it. ## Change - **Restored drafts keep the "saved meanwhile" block** (`public/repeater-info.js`). When a save answers 409, the editor shows the record someone else saved under the form. If the panel re-rendered before the user saved again, the restored draft kept the typed values and the stored revision but lost that block. The draft now stores the conflicting record and restores it with the form. - **Comments only** (`cmd/server/auth_session.go`, `cmd/server/cors.go`): the `bearerCORSPath` and CORS comments now describe the current bearer routes, including the My repeaters list from #2430. No behavior change. ## Tests - `tests/unit/test-repeater-info.js`: a re-mount after a 409 keeps the typed values, the stored revision and the saved-meanwhile block. 32 pass; the new case fails without the fix. - `npx eslint public/repeater-info.js`: clean. - `go build ./...` and `go vet` in `cmd/server`. Co-authored-by: Adam <196335+anieto@users.noreply.github.com>
Release notes and changelog entry for v3.19.0. - `docs/release-notes/v3.19.0.md`: the full notes, also the GitHub release body (`deploy.yml` reads it as `body_path`). - `CHANGELOG.md`: `[Unreleased]` becomes `[3.19.0] - 2026-11-24` with six highlights. The SMTP and map-provider lines that were under `[Unreleased]` are covered by the highlights and the notes. 32 commits since v3.18.0, up to `70dc4453` (#2445): 14 fix, 8 feat, 5 test, 2 ci, 2 docs, 1 refactor. Types come from the PR titles; #2442, #2429 and #2430 have no prefix and count as feat, #2450 as fix. Read before upgrading, in the notes: the one-time `observers` rebuild (#2407, #2445), the content-hash migration now running in the ingestor (#2409), `users.db` schema v10 with accounts on (#2429), and SNR per node from direct receptions only (#2451-#2454). Left out on purpose: #2446 (map picker follow-ups to #2434, not yet approved), for v3.19.1. Not done: no staging run of master before tagging. After merge: tag `v3.19.0` on this PR's squash commit once its `:edge` image carries that revision.
Follow-up to #2415, see #2414.
Situation
A user can claim repeaters, but no page lists the ones they claimed. Claims show on each node page ("Maintained by"), in the admin user detail and in the "Download my data" export. A maintainer of several repeaters has to remember them and open each node page to see whether one went quiet.
Change
GET /api/account/repeaters(browser session; device tokens answer 403) returns the caller's claims. For each one:pubkeyandname.known: false once the node left the analyzer database. The claim stays.roleandclaimedAt.lastHeard: the newer of the last advert and the last transmission certainly from the node, the same sources as the node page's Last Heard.lastRelayed: when its hop prefix last relayed. Only used to mark a silent repeater as uncertain, since the prefix can be shared.status: the saved repeater status, or null.comaintainers: the other active claimers' display names.The list is sorted by name, with unnamed repeaters after, by pubkey. It's built on the existing
RepeaterClaimsByUser,NotifyNodesandLastHeardMap.My account, My repeaters, a new section after Companions:
getNodeStatus, so the threshold matches the node pages and map (infraSilentMs):DELETE /api/repeaters/{pubkey}/claim.#/account?section=repeatersdeep-links to the section, likesection=notifications.Editing stays on the node page, so there's only one editor. The admin user detail and the export are unchanged.
Docs:
openapi.goand the Repeater info section ofdocs/user-guide/accounts.md.Notes
repeater:claimtoken read this route is a one-line addition to the bearer route table, and I'd rather do that there than here.openapi.go,repeater_handlers.go(route registration) andpublic/account.js. Whichever merges second needs a small rebase.Tests
cmd/server/my_repeaters_test.go:tests/unit/test-user-management-ui.js: health sort and chips, escaping, the short-pubkey fallback, status and co-maintainer lines, Unclaim on every row, and the empty state.tests/e2e/test-user-management-e2e.js:Run locally:
make test: all 16 modules OK.sh test-all.shandnode tests/e2e/test-lint-network-calls.js: pass, run innode:24-bookworm.npx eslint public/*.js: 0 errors, the same 87 warnings as master.test-user-management-e2e.jsagainst local e2etest servers with the CI config: 46/46.Not run: the full Playwright shard matrix from CI.