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:
@@ -23,6 +23,24 @@ const sidecar = require('../../sidecarClient')
|
||||
|
||||
const log = core.logger('links')
|
||||
|
||||
/**
|
||||
* A link changed, so a clan member's website account changed (D57).
|
||||
*
|
||||
* Core resolves a Team member's `userId` from the provider's answer, and that
|
||||
* answer comes from this table. Without asking, a member who links today is not
|
||||
* a member of their clan's Team on the site until core's next scheduled sweep —
|
||||
* fifteen minutes by default — which is exactly when a player tries the clan
|
||||
* forum for the first time. A request, not a wait: it returns at once and never
|
||||
* throws into the link flow.
|
||||
*/
|
||||
function linksChanged(reason) {
|
||||
try {
|
||||
core.teams.reconcile({ reason })
|
||||
} catch (err) {
|
||||
log.warn('could not ask core to reconcile Teams after a link change', { reason, error: err.message })
|
||||
}
|
||||
}
|
||||
|
||||
/** What a link looks like to any caller. Never carries a raw code. */
|
||||
function shape(row) {
|
||||
if (!row) return null
|
||||
@@ -131,6 +149,7 @@ async function confirmOne({ server, code, userId }) {
|
||||
|
||||
const link = shape(await db.getBySteamId(steamId))
|
||||
log.info('steam account linked', { steamId, userId, server: server.id })
|
||||
linksChanged('rust account linked')
|
||||
return { ok: true, link }
|
||||
}
|
||||
|
||||
@@ -184,7 +203,9 @@ async function redeem({ code, userId }) {
|
||||
|
||||
/** Remove a link the caller owns. False when they did not hold it. */
|
||||
async function unlinkOwned(steamId, userId) {
|
||||
return (await db.removeOwned(steamId, userId)) > 0
|
||||
const removed = (await db.removeOwned(steamId, userId)) > 0
|
||||
if (removed) linksChanged('rust account unlinked')
|
||||
return removed
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -200,7 +221,9 @@ async function unlinkOwned(steamId, userId) {
|
||||
* and the game one has no operator to name.
|
||||
*/
|
||||
async function unlinkAnyOwner(steamId) {
|
||||
return (await db.removeBySteamId(steamId)) > 0
|
||||
const removed = (await db.removeBySteamId(steamId)) > 0
|
||||
if (removed) linksChanged('rust account unlinked')
|
||||
return removed
|
||||
}
|
||||
|
||||
/**
|
||||
|
||||
Reference in New Issue
Block a user