feat(rust): Teams from first-party clans (phase 9, protocol 6)
A first-party Rust clan is a Team (R5). This module becomes the site's Team provider and answers core from the plugin's `clans` board. Design of record: docs/modules/rust/PLAN.md §24, D47-D58. - The store: rust_clans, rust_clan_members and rust_clan_boards. A clan's identity is <serverId>:<clanId>:<createdMs> (D52), because the game restarts clan ids whenever its clan database version changes. - The provider (D53): getTeams is complete only when every server's board is fresh, supported and untruncated. It is partial when some are, and refuses when none are. Freshness is judged by the website's clock, from when the board's `t` last advanced. - Only a complete board may mark a clan gone. A board at the game's 100-clan ceiling (D55), or one with an unreadable row, proves nothing about what it leaves out. - Leadership is diffed board to board and published (D54). The five clan events are published as team.* kinds, and written to the Team feed as members-only lines (D49). - Core only writes feed items for a Team it already holds. So the last 10 minutes of clan events are re-offered on each board refresh, deduped by a sha1 key: core clamps a dedupeKey to 40 characters, and a readable key would be truncated into collisions. - projectRoster and the clan page share one audience rule (D48): the clan's linked members and staff by default, re-read from the users row. The setting lives on Admin > Rust visibility, which also warns about uMod Clans (D47) and the ceiling. - Public: GET servers/:id/clans (the list is public, D58) and GET clans/:externalId. The client adds a Clans tab and /rust/clans/:externalId, with three module slots for core's notify, activity and forum contributions (D56). - Linking and unlinking an account ask core to reconcile Teams (D57). - The clan kinds are staff-class in the public feed allowlist. - PROTOCOL_VERSION is now 6. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_01E14m6SuuY6i1vASFeGDBeY
This commit is contained in:
@@ -12,6 +12,13 @@
|
||||
// The page says what "who is online" covers, because it is wider than the tab
|
||||
// of the same name: the killfeed, chat and joins in the feed, and the
|
||||
// leaderboard's "last seen" all name a player who was on at a given moment.
|
||||
//
|
||||
// Phase 9 adds a second setting beside it: who may see a CLAN ROSTER (D48). It
|
||||
// defaults to the clan's own members and staff, and widening it widens online
|
||||
// status too, because a roster row carries it — the page says so. The same card
|
||||
// lists each server's clan board: a server whose clans cannot be read, one at
|
||||
// the game's 100-clan ceiling (D55), and one running the uMod Clans plugin,
|
||||
// whose clans are a separate system and never Teams (D47).
|
||||
|
||||
import { useCallback, useEffect, useState } from 'react'
|
||||
|
||||
@@ -26,6 +33,18 @@ const LABEL = {
|
||||
public: 'Everyone',
|
||||
}
|
||||
|
||||
const CLAN_LABEL = {
|
||||
members: 'The clan’s members and staff',
|
||||
signed_in: 'Signed-in members',
|
||||
public: 'Everyone',
|
||||
}
|
||||
|
||||
const CLAN_DESCRIBE = {
|
||||
members: 'Players whose linked Rust account is in the clan, plus admins and moderators. The default.',
|
||||
signed_in: 'Anybody with an account on this site.',
|
||||
public: 'Anybody at all, signed in or not.',
|
||||
}
|
||||
|
||||
const DESCRIBE = {
|
||||
staff: 'Admins and moderators. The default.',
|
||||
signed_in: 'Anybody with an account on this site.',
|
||||
@@ -66,6 +85,7 @@ export default function Visibility() {
|
||||
const { data, error: loadError } = useAsync(() => api.adminVisibility.read(), [reloads])
|
||||
|
||||
const [fleet, setFleet] = useState('staff')
|
||||
const [clanRoster, setClanRoster] = useState('members')
|
||||
const [servers, setServers] = useState({})
|
||||
const [busy, setBusy] = useState(false)
|
||||
const [error, setError] = useState('')
|
||||
@@ -76,6 +96,7 @@ export default function Visibility() {
|
||||
// the site's word rather than what this page sent.
|
||||
const load = useCallback((state) => {
|
||||
setFleet(state.presence.fleet)
|
||||
setClanRoster((state.clans && state.clans.roster) || 'members')
|
||||
setServers(Object.fromEntries(state.presence.servers.map((s) => [s.id, s.override || INHERIT])))
|
||||
}, [])
|
||||
|
||||
@@ -91,7 +112,9 @@ export default function Visibility() {
|
||||
|
||||
const dirtyFleet = fleet !== data.presence.fleet
|
||||
const dirtyServers = rows.filter((s) => (servers[s.id] ?? INHERIT) !== (s.override || INHERIT))
|
||||
const dirty = dirtyFleet || dirtyServers.length > 0
|
||||
const clans = data.clans || { audiences: [], roster: 'members', servers: [] }
|
||||
const dirtyClans = clanRoster !== clans.roster
|
||||
const dirty = dirtyFleet || dirtyServers.length > 0 || dirtyClans
|
||||
|
||||
const effective = (id) => servers[id] || fleet
|
||||
const widened = fleet !== 'staff' || rows.some((s) => effective(s.id) !== 'staff')
|
||||
@@ -104,6 +127,7 @@ export default function Visibility() {
|
||||
try {
|
||||
const body = {}
|
||||
if (dirtyFleet) body.fleet = fleet
|
||||
if (dirtyClans) body.clanRoster = clanRoster
|
||||
if (dirtyServers.length) {
|
||||
body.servers = Object.fromEntries(dirtyServers.map((s) => [s.id, servers[s.id] || null]))
|
||||
}
|
||||
@@ -175,6 +199,32 @@ export default function Visibility() {
|
||||
</p>
|
||||
)}
|
||||
|
||||
<Card title="Clan rosters" subtitle="who is in each clan, on every server">
|
||||
<div className="sans" style={{ display: 'flex', alignItems: 'center', gap: 12, fontSize: '0.86rem' }}>
|
||||
<select
|
||||
value={clanRoster}
|
||||
onChange={(e) => setClanRoster(e.target.value)}
|
||||
style={selectStyle}
|
||||
aria-label="Who may see a clan roster"
|
||||
>
|
||||
{clans.audiences.map((a) => (
|
||||
<option key={a} value={a}>{CLAN_LABEL[a] || a}</option>
|
||||
))}
|
||||
</select>
|
||||
<span className="dim" style={{ fontSize: '0.78rem' }}>{CLAN_DESCRIBE[clanRoster]}</span>
|
||||
</div>
|
||||
<p className="sans dim" style={{ fontSize: '0.78rem', margin: '10px 0 0' }}>
|
||||
Each clan’s name, colour, score and member count are always public.
|
||||
</p>
|
||||
{clanRoster !== 'members' && (
|
||||
<p className="sans" style={{ color: '#d08a2a', fontSize: '0.8rem', margin: '8px 0 0' }}>
|
||||
A roster also shows which members are online right now, so this shows who is on to{' '}
|
||||
{clanRoster === 'public' ? 'everyone' : 'every signed-in member'} as well.
|
||||
</p>
|
||||
)}
|
||||
<ClanBoards servers={clans.servers || []} />
|
||||
</Card>
|
||||
|
||||
<div className="sans" style={{ display: 'flex', alignItems: 'center', gap: 12 }}>
|
||||
<button type="submit" className="btn" disabled={busy || !dirty}>
|
||||
{busy ? 'Saving…' : 'Save'}
|
||||
@@ -186,6 +236,38 @@ export default function Visibility() {
|
||||
)
|
||||
}
|
||||
|
||||
/**
|
||||
* What each server's clan board says about itself. Only the servers with
|
||||
* something to report are listed: a board that is current, complete and read
|
||||
* normally is the case that needs no sentence.
|
||||
*/
|
||||
function ClanBoards({ servers }) {
|
||||
const notes = []
|
||||
for (const s of servers) {
|
||||
if (s.umodClans) {
|
||||
notes.push([s, 'is running the uMod Clans plugin. Its clans are a separate system from the game’s own, and only the game’s clans appear on this site.'])
|
||||
}
|
||||
if (!s.supported) {
|
||||
notes.push([s, s.reason ? `cannot report its clans: ${s.reason}.` : 'has not reported its clans yet.'])
|
||||
} else if (s.truncated) {
|
||||
notes.push([s, 'is at the game’s limit of 100 listed clans, so clans beyond the top 100 by score are not shown, and a disbanded clan is not removed until it drops below.'])
|
||||
} else if (!s.fresh) {
|
||||
notes.push([s, 'has not reported its clans recently, so they are shown as last reported.'])
|
||||
}
|
||||
}
|
||||
if (!notes.length) return null
|
||||
return (
|
||||
<ul className="sans" style={{ margin: '12px 0 0', paddingLeft: 18, fontSize: '0.8rem' }}>
|
||||
{notes.map(([s, text], i) => (
|
||||
// eslint-disable-next-line react/no-array-index-key
|
||||
<li key={`${s.id}-${i}`} style={{ margin: '4px 0' }}>
|
||||
<strong style={{ color: 'var(--head)' }}>{s.name}</strong> {text}
|
||||
</li>
|
||||
))}
|
||||
</ul>
|
||||
)
|
||||
}
|
||||
|
||||
const selectStyle = {
|
||||
background: 'var(--panel-flat, transparent)',
|
||||
color: 'var(--text)',
|
||||
|
||||
Reference in New Issue
Block a user