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
56 lines
2.2 KiB
JavaScript
56 lines
2.2 KiB
JavaScript
// ── SQL for the visibility settings ───────────────────────────────────────
|
|
//
|
|
// Two stores for one decision: the fleet default in `rust_settings`, and an
|
|
// optional per-server override on `rust_servers`. See `schema.sql` for why each
|
|
// lives where it does.
|
|
|
|
const core = require('../../core')
|
|
|
|
const SETTINGS = 'rust_settings'
|
|
const SERVERS = 'rust_servers'
|
|
|
|
/** One setting's stored value, or `null` when nobody has ever set it. */
|
|
async function getSetting(key) {
|
|
const rows = await core.query(`SELECT value FROM ${SETTINGS} WHERE setting_key = ?`, [key])
|
|
return rows[0] ? rows[0].value : null
|
|
}
|
|
|
|
async function setSetting(key, value, userId = null) {
|
|
await core.query(
|
|
`INSERT INTO ${SETTINGS} (setting_key, value, updated_by, updated_at)
|
|
VALUES (?, ?, ?, CURRENT_TIMESTAMP)
|
|
ON DUPLICATE KEY UPDATE value = VALUES(value), updated_by = VALUES(updated_by),
|
|
updated_at = CURRENT_TIMESTAMP`,
|
|
[key, value, userId],
|
|
)
|
|
}
|
|
|
|
/** One server's override, `null` for "inherit", or `undefined` when there is no such server. */
|
|
async function getServerPresence(serverId) {
|
|
const rows = await core.query(`SELECT presence_audience AS presence FROM ${SERVERS} WHERE id = ?`, [serverId])
|
|
return rows[0] ? rows[0].presence : undefined
|
|
}
|
|
|
|
/** Every configured server with its override, in the operator's own order. */
|
|
async function listServerPresence() {
|
|
return core.query(
|
|
`SELECT id, name, enabled, presence_audience AS presence
|
|
FROM ${SERVERS}
|
|
ORDER BY sort_order ASC, id ASC`,
|
|
)
|
|
}
|
|
|
|
/**
|
|
* Sets or clears (`null`) one server's override.
|
|
*
|
|
* Returns nothing, deliberately. `affectedRows` would look like a way to tell
|
|
* "no such server" from success, and it is not one: without `foundRows` an
|
|
* UPDATE writing the value already there reports 0, and whether core's pool sets
|
|
* that flag is core's business. The model checks existence with a read first.
|
|
*/
|
|
async function setServerPresence(serverId, value) {
|
|
await core.query(`UPDATE ${SERVERS} SET presence_audience = ? WHERE id = ?`, [value, serverId])
|
|
}
|
|
|
|
module.exports = { getSetting, setSetting, getServerPresence, listServerPresence, setServerPresence }
|