The org lead's rule, settled 2026-09-22: who is online is always the
narrowest audience - staff - unless an operator deliberately widens it,
and a count is fine where a list of names is not.
The public site broke that in three places since phase 4. The Online
tab named every player, the feed carried joins, respawns, deaths, chat
and tallies, and the leaderboard's lastSeen - refreshed every minute by
a gather tally - said who was on as plainly as either. All three now
sit behind one setting:
* PRESENCE_KINDS, a subset of the public allowlist, gated per request.
Below the audience the feed keeps the server's own story (wipe, start,
shutdown) and says presenceHidden rather than looking quiet.
* the Online route answers { players: [], hidden, count, audience } -
same shape, so an older client renders empty rather than breaking.
* rungs staff / signed_in / public, fleet-wide default in a new
rust_settings table with an optional per-server override on
rust_servers; an unknown stored word narrows to staff.
* the viewer's standing is RE-READ from the users row (ctx.users.getById),
not taken from the token, so a demotion or a ban applies on the next
request. Walked: a moderator demoted mid-session lost the roll call on
the same cookie.
* per-viewer answers are Cache-Control: private, no-store.
* GET/PUT /admin/rust/visibility (requireRole admin) and an admin page,
Rust visibility; every save is one activity-log row.
The browser walk also found every empty state in this module rendering
as a blank box. Core's EmptyState renders children only; this module
passed title/message (the shape the Integration Kit template teaches)
and React dropped both without a word. Fixed module-side with a small
Empty wrapper - nothing core or module-uo renders changes - and a client
test that refuses a titled EmptyState or a PageHeader subtitle.
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01E14m6SuuY6i1vASFeGDBeY
52 lines
3.0 KiB
JavaScript
52 lines
3.0 KiB
JavaScript
// ── Admin · Rust · Visibility ─────────────────────────────────────────────
|
||
//
|
||
// Mounted under the admin tier's `/rust` prefix, so every path here is
|
||
// `/api/v1/admin/rust/visibility`. Who may see what the servers say about the
|
||
// people on them — a fourth subject beside the bridge, the permissions and the
|
||
// mod configuration.
|
||
//
|
||
// **Every route is `requireRole('admin')`.** The tier's own gate admits editors
|
||
// and moderators, and a moderator widening the roll call to the public is the
|
||
// decision the org lead settled should be deliberate. Reading is gated the same
|
||
// as writing: the screen is one form, and a view of the settings without the
|
||
// power to change them is not something anybody has asked for.
|
||
|
||
const core = require('../../core')
|
||
|
||
const express = core.express
|
||
const visibility = require('./visibility.controller')
|
||
const { requireRole, validate } = core.middleware
|
||
const { body } = core.validator
|
||
|
||
const visibilityRouter = express.Router()
|
||
|
||
const AUDIENCES = ['staff', 'signed_in', 'public']
|
||
|
||
visibilityRouter.get(
|
||
'/',
|
||
// #swagger.tags = ['Admin · Rust']
|
||
// #swagger.summary = 'Who may see who is online'
|
||
// #swagger.description = 'The fleet default and every server’s optional override. It governs the Online list, every feed item that names a player who was on the server (connects, respawns, deaths, chat, tallies) and the leaderboard’s `lastSeen`. The default is `staff`: nothing names who is online until an operator widens it. The player count is public at every setting.'
|
||
/* #swagger.responses[200] = { description: 'The fleet default and each server', content: { "application/json": { schema: { $ref: "#/components/schemas/RustVisibility" } } } } */
|
||
requireRole('admin'),
|
||
visibility.read,
|
||
)
|
||
|
||
visibilityRouter.put(
|
||
'/',
|
||
// #swagger.tags = ['Admin · Rust']
|
||
// #swagger.summary = 'Change who may see who is online'
|
||
// #swagger.description = 'Sets the fleet default, one or more server overrides, or both. A server set to `null` follows the fleet default again. Validated whole before anything is written: a request naming a server that does not exist changes nothing.'
|
||
/* #swagger.requestBody = { required: true, content: { "application/json": { schema: { $ref: "#/components/schemas/RustVisibilityUpdate" } } } } */
|
||
/* #swagger.responses[200] = { description: 'Saved; answers the new state', content: { "application/json": { schema: { $ref: "#/components/schemas/RustVisibility" } } } } */
|
||
/* #swagger.responses[400] = { description: 'An audience that does not exist' } */
|
||
/* #swagger.responses[404] = { description: 'A server that does not exist' } */
|
||
requireRole('admin'),
|
||
body('fleet').optional().isIn(AUDIENCES).withMessage(`fleet must be one of ${AUDIENCES.join(', ')}`),
|
||
body('servers').optional().isObject().withMessage('servers maps a server id to an audience or null'),
|
||
validate,
|
||
visibility.update,
|
||
)
|
||
|
||
module.exports = visibilityRouter
|