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:
@@ -33,6 +33,7 @@
|
||||
|
||||
const core = require('./core')
|
||||
|
||||
const clans = require('./model/clans/clans.model')
|
||||
const db = require('./model/events/events.db')
|
||||
const links = require('./model/links/links.model')
|
||||
const permissionsDb = require('./model/permissions/permissions.db')
|
||||
@@ -191,6 +192,24 @@ async function apply(serverId, item) {
|
||||
await permissionsDb.markDirty(serverId)
|
||||
break
|
||||
|
||||
// ── Protocol 6: first-party clans ──────────────────────────────────────
|
||||
//
|
||||
// Each one is told to core as it happens (`ctx.teams.publish`) and written
|
||||
// to the clan's Team feed as a members-only line (D49). Neither is the
|
||||
// record: the `clans` board the plugin re-sends a few seconds later is what
|
||||
// the store is rebuilt from, so an event this module never saw costs a
|
||||
// feed line and nothing else.
|
||||
//
|
||||
// No `touchPlayer` here, on purpose: it moves `last_seen`, and a kick is
|
||||
// done TO somebody who may be offline. `model/clans` notes names without it.
|
||||
case 'clan.created':
|
||||
case 'clan.disbanded':
|
||||
case 'clan.member.added':
|
||||
case 'clan.member.left':
|
||||
case 'clan.member.kicked':
|
||||
await clans.applyEvent(serverId, frame)
|
||||
break
|
||||
|
||||
default:
|
||||
// Stored, not counted. Moderation frames, the server lifecycle, and
|
||||
// anything a newer protocol sends that this build does not understand.
|
||||
@@ -284,6 +303,22 @@ async function applyBoards(serverId, boards) {
|
||||
if (presence && Array.isArray(presence.players)) {
|
||||
await db.replacePresence(serverId, presence.players)
|
||||
}
|
||||
|
||||
// Clans only once the game has spoken at all. A sidecar that has never heard
|
||||
// from its plugin holds no boards, and recording "no clan board" then would
|
||||
// blame the plugin's protocol for a game server that is simply not up. Left
|
||||
// alone, the stored board ages past fresh on its own, which is the true answer.
|
||||
if (boards && boards['server.hello']) {
|
||||
// Fenced: clans are the one board here that core's Teams depend on, and a
|
||||
// failure applying them must cost the clans rather than the presence board
|
||||
// above or the server state the caller writes next.
|
||||
try {
|
||||
await clans.applyBoard(serverId, boards.clans)
|
||||
await clans.reofferActivity(serverId)
|
||||
} catch (err) {
|
||||
log.warn('could not apply the clan board', { server: serverId, error: err.message })
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
module.exports = { apply, applyBoards, ingestServer, BATCH, MAX_BATCHES_PER_TICK }
|
||||
|
||||
Reference in New Issue
Block a user