Skip to content

feat: add a super-admin user directory and page people on Discord - #406

Merged
fclairamb merged 26 commits into
mainfrom
batch/2026-09-19-02
Sep 20, 2026
Merged

fclairamb merged 26 commits into
mainfrom
batch/2026-09-19-02

Conversation

@fclairamb

Copy link
Copy Markdown
Owner

Two specs from specs/todos/, implemented on a batch branch and archived to specs/done/2026/09/.

What & why

A super admin can now list and search users (specs/done/2026/09/2026-09-19-04)

An operator had no way to answer "does [email protected] have an account, and which orgs is she in?". Membership was only visible from inside an org, so you had to guess the org first, and accounts belonging to no org or to several were invisible.

New GET /api/v1/system/users behind RequireAuth + RequireSuperAdmin, and a Users tab in server settings.

  • Search and paging happen in SQL, not in memory. The entitlements admin list loads every org and filters in Go, which does not survive a users table.
  • The response is an explicit allow-list DTO. models.User carries PasswordHash, TOTPSecret and TOTPRecoveryCodes, so a test asserts on the serialized JSON bytes that none of them appear, with a positive control that email does.
  • ListMembersByUsers resolves a whole page's memberships in one user_uid IN (...) query, so a page costs two queries instead of 1+N.
  • % and _ in the query are escaped, so typing % matches a literal %.
  • Soft deletes are handled in three separate places: a deleted user, a deleted membership, and a membership in a deleted org. Each has its own test.
  • Read-only. No promote-to-super-admin, no force password reset, no delete, no impersonate.

A person can be paged on Discord (specs/done/2026/09/2026-09-19-05)

The Discord bot could alert a channel but could not page a human. user_contacts knew Slack, Telegram, WhatsApp, Pushover, ntfy and web push, and not Discord, so every per-person path skipped it: escalation steps targeting a person, operator notices, the account page's Test button, and support attribution for a DM the Gateway already captured.

  • New discord contact type, delivered by the instance bot. The DM channel id is cached on the contact so paging does not re-open a DM on every notice, and a re-connect does not wipe the cache.
  • Discord error 50007 (DMs closed, or no shared server) maps to unavailable, so paging coverage falls through to the member's next route instead of counting as delivered. A plain 5xx does not, and there is a test for that distinction.
  • A typed snowflake is rejected at contact creation. Anyone could otherwise bind a stranger's id and have that person DMed with our incidents. Only two sources bind a contact: a Discord sign-in already on file, or an OAuth link round trip that mints no session and creates no organization.
  • On-call mentions now fall back to a self-declared identity, the Discord twin of the Slack fallback, at all three call sites. An admin mapping still wins when present. There is no workspace scoping, because a snowflake is global rather than per-guild, and the doc comment says what that costs: a mention only pings a member who is in that guild.
  • Checks can route to one person's DMs. The picker lists org members with a resolved Discord identity, not the guild member list (that needs the privileged GUILD_MEMBERS intent).
  • DM channels do not support threads, so the sender skips thread creation and un-archiving for a DM and posts follow-ups as plain messages referencing the original.
  • Test parity: 4 new Playwright files plus DM tab tests on the existing one, and Go tests in opsnotify, jobtypes, usernotifications, identitylink, discord and support.

Two deviations worth reviewing

The migration is a SECTION in 022_v0_30_0, not the 023 the spec asked for. v0.30.0 has not shipped and wiki/conventions/database.md says not to open 023. A dev database that already ran an earlier draft of 022 must be reset (SP_DB_RESET=true), never repaired.

Acknowledge pressed inside a DM was broken and is fixed here, which the spec did not ask for. A DM interaction carries no guild_id, so Acknowledge from the new DM action row would have answered "this server is not connected". The org is now resolved presser-first from their verified discord contact, which is also the authorization: an incident UID alone must never silence someone else's page. GetIncident is org-scoped in both dialects, and a stranger, a revoked binding and a cross-org incident are each refused by a test.

Unrelated, one line

server/pkg/client/Makefile installed oapi-codegen@latest while go.mod pins v2.8.0. Pinned it.

How to test

make build-backend lint-back test
make build-dash0 && cd web/dash0 && bun run lint && bun run test:unit

Full dash0 Playwright suite, run against a side-car on a dedicated solidping_e2e database: 840 passed, 12 skipped, 0 failed (23.9 min).

The first run of that suite was red, and it was a real finding rather than a flake. server-users.spec.ts asserted [email protected] was visible on the unsearched first page. That holds in isolation and fails at test 744 of 853, because by then the suite has created 88 users and the page shows 50 ordered created_at DESC, so the oldest seeded user is on page 2. Both tests are re-grounded on search, which also proves search finds the row, and the non-matching-query negative control is kept. The org badge assertion went from "test" to "test · admin", since the seeded user is in test, test2 and test3 and the loose match passed on the wrong badge.

One pre-existing flake showed up and is not from this branch: login.spec.ts:470 (passkey RP-ID mismatch) failed twice then passed. Nothing here touches WebAuthn, and the same test passed first try on identical code an hour earlier. go-webauthn was bumped to v0.18.2 on main in cadacf7, which is the likelier trigger. Being tracked separately.

Checklist

  • make fmt && make lint && make test pass locally (make build-dash0 && cd web/dash0 && bun run lint && bun run test:unit if web/dash0 changed)
  • Tests added or updated for the change
  • Docs updated (web/docs/) if user-visible; wiki (wiki/) if operational
  • Schema changes: appended a SECTION: to the current unreleased migration file under server/internal/db/postgres/migrations/ and server/internal/db/sqlite/migrations/ (one consolidated migration per release, per engine — see wiki/conventions/database.md), not a new numbered file

🤖 Generated with Claude Code

fclairamb and others added 25 commits September 19, 2026 22:08
Backs the super-admin user directory: SearchUsers pages the global user
list with a case-insensitive, wildcard-escaped substring search on
email/name, and ListMembersByUsers batches org-membership lookups for a
page of users into one query instead of one query per row. Implemented in
both the postgres and sqlite dialects.

Co-Authored-By: Claude Sonnet 5 <[email protected]>
Exposes a searchable, paged, read-only directory over the global user
table with org memberships attached, gated behind RequireSuperAdmin. The
response is an explicit allow-list DTO (never models.User), so
passwordHash/totpSecret/totpRecoveryCodes can never leak onto the wire.

Co-Authored-By: Claude Sonnet 5 <[email protected]>
…ler)

401/403/200 with a positive control, case-insensitive email/name search
with literal-%% escaping, limit/offset paging and total, soft-delete
exclusions (user, membership, org), the empty-slice ListMembersByUsers
fast path, and a raw-JSON assertion that the response never carries
passwordHash/totpSecret/totpRecoveryCodes.

Also fixes an unqualified "deleted_at IS NULL" in the ListMembersByUsers
relation apply-closure that SQLite flagged as an ambiguous column between
organization_member and organization.

Co-Authored-By: Claude Sonnet 5 <[email protected]>
bun.In is deprecated (staticcheck) -> bun.List, matching the codebase's
existing IN-clause pattern; forcetypeassert/prealloc/varnamelen/lll
cleanups in the new tests and handler.

Co-Authored-By: Claude Sonnet 5 <[email protected]>
New Users tab under /orgs/:org/server, modelled on the entitlements admin
page: debounced search, a paged table (email, name, org badges linking to
the entitlements detail page, status flags, last active, created), and
PermissionDenied on a 403 rather than a redirect. Adds useAdminUsersList +
AdminUserRow/AdminOrgMembership to hooks.ts and locale keys to all four
languages.

Co-Authored-By: Claude Sonnet 5 <[email protected]>
Tab visibility, the search/clear round trip against real seeded data,
PermissionDenied on a 403, and the non-superadmin gate — mirrors
server-entitlements.spec.ts's shape. Type-checks and lints clean
(bun run typecheck:e2e / lint:e2e); not run end-to-end here because the
local :4000 devloop isn't in SP_RUNMODE=test and this task must not stand
up its own side-car server.

Co-Authored-By: Claude Sonnet 5 <[email protected]>
Fixes mockDBService (internal/notifications) to implement the two new
db.Service methods (SearchUsers, ListMembersByUsers), which lint-back's
typecheck caught. Full gate green: make build-backend lint-back test,
make build-dash0, bun run lint (no new errors beyond the documented
pre-existing debt), bun run test:unit (1753 passed, locale parity holds).

Co-Authored-By: Claude Sonnet 5 <[email protected]>
The install-deps target installed @latest while go.mod pins v2.8.0, so a
developer running it got whatever the newest release happened to be. That
drift has broken codegen here before.

Co-Authored-By: Claude Opus 5 <[email protected]>
- opsnotify + escalation step page a discord contact through the instance bot
- 50007 degrades to "unavailable" so paging falls through to the next route
- CreateContact rejects a typed snowflake; connect (sign-in) and OAuth link mode
  are the only two sources
- link mode mints no session and creates no organization, by construction
- identitylink.DeclaredDiscordIdentity backs on-call mentions, the admin mapping
  table and the account page
- support attributes a captured Discord DM to the member

Co-Authored-By: Claude Opus 5 <[email protected]>
…d OAuth link-mode negatives

Co-Authored-By: Claude Opus 5 <[email protected]>
… paging, support attribution and the DM sender

Co-Authored-By: Claude Opus 5 <[email protected]>
…gestion, Gateway status, account page, DM tab)

Co-Authored-By: Claude Opus 5 <[email protected]>
…ment the DM paths

A DM interaction carries no guild_id, so the guild-keyed org lookup answered
"this server is not connected" for a button that rendered perfectly. The org now
comes from the presser's own verified discord contact, narrowed to the org owning
that incident — presser first, so an incident UID is never enough on its own.

Also clears every golangci-lint finding and documents the member DM contact, the
DM destination tab and the 50007 remedy.

Co-Authored-By: Claude Opus 5 <[email protected]>
…ed first page

Both failures shared one root cause: [email protected] is the oldest seeded
user (created_at DESC ordering), so on a full-suite run with 88+ users
created after it, it no longer lands on the unsearched first page of 50.
Re-ground both tests on search reaching it instead — which is strictly
stronger, since it also proves search actually finds it — keep the
non-matching-query negative control, and tighten the org-badge assertion
to the specific "test · admin" badge text ([email protected] belongs to
test/test2/test3, so a bare "test" substring match would also pass on
test2's badge).

Co-Authored-By: Claude Sonnet 5 <[email protected]>
@fclairamb
fclairamb enabled auto-merge (squash) September 20, 2026 10:56
@fclairamb
fclairamb merged commit 3506c8f into main Sep 20, 2026
19 checks passed
@fclairamb
fclairamb deleted the batch/2026-09-19-02 branch September 20, 2026 11:40
fclairamb added a commit that referenced this pull request Sep 21, 2026
🤖 I have created a release *beep* *boop*
---


##
[0.30.0](v0.29.2...v0.30.0)
(2026-09-21)


### Features

* add a super-admin user directory and page people on Discord
([#406](#406))
([3506c8f](3506c8f))
* **discord:** finish the bot migration — retire the webhook transport
and close the frontend gaps
([#409](#409))
([e89710d](e89710d))
* group-based status page sections, ICMP burst sampling, and form
exposure ([#411](#411))
([e3c87e8](e3c87e8))


### Bug Fixes

* **deps:** update module github.com/urfave/cli/v3 to v3.13.0
([#408](#408))
([5c10ab5](5c10ab5))

---
This PR was generated with [Release
Please](https://github.com/googleapis/release-please). See
[documentation](https://github.com/googleapis/release-please#release-please).
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant