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
158 lines
6.1 KiB
JavaScript
158 lines
6.1 KiB
JavaScript
// ── The feed: what happened on one server ─────────────────────────────────
|
|
//
|
|
// Rows come from `/public/rust/servers/:id/events`, which serves a default-deny
|
|
// ALLOWLIST (`server/catalogue.js`). Everything carrying an IP address, a
|
|
// player's report about another player, or the grid square somebody's base is in
|
|
// is stored and never answered here — so this component cannot leak one by
|
|
// forgetting to filter, which is the point of the boundary living on the server.
|
|
//
|
|
// It polls (org lead, phase 4): every twenty seconds while the tab is visible,
|
|
// paused when it is not. `usePolled` keeps the rows on screen across a refresh —
|
|
// see the comment at the top of that file for why core's `useAsync` cannot do
|
|
// this job.
|
|
|
|
import { ErrorState, Loading } from '../core.js'
|
|
import Empty from './Empty.jsx'
|
|
import { describe, FILTERS, kindsFor } from '../lib/feed.js'
|
|
import { ago, clock } from '../lib/format.js'
|
|
import usePolled from '../hooks/usePolled.js'
|
|
import api from '../api.js'
|
|
import { hiddenMessage } from './Online.jsx'
|
|
|
|
const TONE = {
|
|
kill: 'var(--accent-bright)',
|
|
death: 'var(--muted)',
|
|
join: 'var(--mode-live, #5fb98a)',
|
|
leave: 'var(--dim)',
|
|
chat: 'var(--text)',
|
|
server: 'var(--mode-maint, #e6c26a)',
|
|
other: 'var(--muted)',
|
|
}
|
|
|
|
export default function Feed({ serverId, wipeId, filter, onFilter }) {
|
|
const kinds = kindsFor(filter)
|
|
|
|
const { data, error, loading, at } = usePolled(
|
|
() => api.servers.events(serverId, { kinds, wipe: wipeId, limit: 100 }),
|
|
// The key is the QUESTION. Changing server, wipe or filter blanks the rows,
|
|
// because what is on screen is an answer to a different one; a poll tick
|
|
// does not, because it is the same question asked again.
|
|
{ key: `${serverId}|${wipeId || ''}|${filter}`, intervalMs: 20_000 },
|
|
)
|
|
|
|
const events = data ? data.events : []
|
|
|
|
return (
|
|
<div>
|
|
<div
|
|
className="sans"
|
|
style={{ display: 'flex', flexWrap: 'wrap', gap: 10, alignItems: 'center', marginBottom: 16 }}
|
|
>
|
|
<label style={{ color: 'var(--dim)', fontSize: '0.78rem' }}>
|
|
Showing{' '}
|
|
<select
|
|
value={filter}
|
|
onChange={(e) => onFilter(e.target.value)}
|
|
style={selectStyle}
|
|
>
|
|
{FILTERS.map((f) => (
|
|
<option key={f.id} value={f.id}>{f.label}</option>
|
|
))}
|
|
</select>
|
|
</label>
|
|
|
|
{/* What a refresh is FOR: saying when the page last managed one. Without
|
|
it a feed that stopped updating looks exactly like a quiet server. */}
|
|
{at && (
|
|
<span style={{ color: 'var(--dim)', fontSize: '0.74rem' }}>updated {ago(at)}</span>
|
|
)}
|
|
{error && (
|
|
<span style={{ color: 'var(--mode-maint, #e6c26a)', fontSize: '0.74rem' }}>
|
|
the last refresh failed — showing what we had
|
|
</span>
|
|
)}
|
|
</div>
|
|
|
|
{loading && <Loading />}
|
|
|
|
{/* An error with nothing to fall back on is the only case that takes over
|
|
the panel. A failed REFRESH keeps the rows and says so in the line
|
|
above, because a site whose premise is "it renders while the game is
|
|
off" must not blank itself the first time a request does. */}
|
|
{error && !data && <ErrorState error={error} />}
|
|
|
|
{/* Below the operator's presence audience the server withholds every item
|
|
that names a player who was on — the killfeed, chat, joins — and keeps
|
|
only the server's own story. Said once, above the rows, so a thin feed
|
|
reads as withheld rather than as a quiet server. */}
|
|
{data && data.presenceHidden && (
|
|
<p className="sans" style={{ color: 'var(--dim)', fontSize: '0.8rem', marginTop: 0 }}>
|
|
Joins, deaths and chat are not shown. {hiddenMessage(data.presenceAudience, 'what players did')}
|
|
</p>
|
|
)}
|
|
|
|
{data && events.length === 0 && (
|
|
<Empty
|
|
title="Nothing here yet"
|
|
message={
|
|
data.presenceHidden
|
|
? 'Nothing this server has reported about itself matches.'
|
|
: 'Nothing this server has reported matches. A server that has just been added has no history until it says something.'
|
|
}
|
|
/>
|
|
)}
|
|
|
|
{events.length > 0 && (
|
|
<ol style={{ listStyle: 'none', margin: 0, padding: 0 }}>
|
|
{events.map((event) => {
|
|
const line = describe(event)
|
|
return (
|
|
<li
|
|
key={event.id}
|
|
style={{
|
|
display: 'flex',
|
|
gap: 12,
|
|
alignItems: 'baseline',
|
|
padding: '7px 0',
|
|
borderBottom: '1px solid var(--line-soft, var(--line))',
|
|
}}
|
|
>
|
|
<time
|
|
className="sans"
|
|
dateTime={new Date(event.t).toISOString()}
|
|
title={new Date(event.t).toLocaleString()}
|
|
style={{ flex: 'none', color: 'var(--dim)', fontSize: '0.74rem', minWidth: '5.6rem' }}
|
|
>
|
|
{clock(event.t)}
|
|
</time>
|
|
<span style={{ color: TONE[line.tone] || 'var(--muted)', fontSize: '0.92rem' }}>
|
|
{line.actor && <strong style={{ color: 'var(--ink)' }}>{line.actor}</strong>}
|
|
{line.actor && (line.join || ' ')}
|
|
{line.verb}
|
|
{line.subject && ' '}
|
|
{line.subject && <strong style={{ color: 'var(--ink)' }}>{line.subject}</strong>}
|
|
{line.detail && (
|
|
<span className="sans" style={{ color: 'var(--dim)', fontSize: '0.76rem' }}>
|
|
{' · '}
|
|
{line.detail}
|
|
</span>
|
|
)}
|
|
</span>
|
|
</li>
|
|
)
|
|
})}
|
|
</ol>
|
|
)}
|
|
</div>
|
|
)
|
|
}
|
|
|
|
const selectStyle = {
|
|
background: 'var(--panel-flat, transparent)',
|
|
color: 'var(--text)',
|
|
border: '1px solid var(--line)',
|
|
borderRadius: 'var(--radius-input, 6px)',
|
|
padding: '3px 8px',
|
|
fontSize: '0.78rem',
|
|
}
|