Files
Module-Rust/server/router/admin/visibility.controller.js
wtclaude cc185db26b feat(rust): the rewards — tally, kit reward, chat and the news leg (phase 13b, protocol 10)
Four event verbs and the announce leg, per PLAN.md §29:

- rust.participation.open / .collect: the plugin counts who takes part
  (seconds, kills or both, in a zone this run opened or the whole server)
  and collect files them as the run's participants, keyed by Steam id.
- rust.kit.entitle: the five recipient modes (D101), rows in the new
  rust_perm_run_grants (D84) unioned into the permission push, one extra
  use of the kit per reward as site-held credits on perm.sync (D103),
  and the rust.kit.entitled notice deferred from phase 10 (D64).
- rust.announce: one server or every server (D105).
- rust.chat announce leg, speaking only on servers whose new news switch
  is on (D104) - a card on Admin -> Rust visibility (D106).

Budgets rust.grants and rust.announcements; the kit source and four
fixed-choice sources (core has no enum param type). rust_perm_run_grants
carries core's idempotency key so a revert of a lost answer can find its
rows. Protocol 10.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01E14m6SuuY6i1vASFeGDBeY
2026-09-24 07:00:44 -05:00

52 lines
1.9 KiB
JavaScript

// ── Admin · Rust · Visibility — the handlers ──────────────────────────────
const core = require('../../core')
const clans = require('../../model/clans/clans.model')
const visibility = require('../../model/visibility/visibility.model')
const log = core.logger('visibility')
/**
* The page's whole state: both settings, and each server's clan board beside
* the roster setting. The board is where "this server runs the uMod Clans
* plugin, whose clans are not Teams" (D47) and "this server is at the game's
* 100-clan ceiling" (D55) come from.
*/
async function describe() {
const [settings, boards] = await Promise.all([visibility.describe(), clans.boardsForAdmin()])
return { ...settings, clans: { ...settings.clans, servers: boards } }
}
async function read(req, res) {
try {
res.json(await describe())
} catch (err) {
log.error('failed to read visibility settings', { error: err.message })
res.status(500).json({ message: 'Failed to read the visibility settings' })
}
}
async function update(req, res) {
try {
const { fleet, servers, clanRoster, news } = req.body || {}
const result = await visibility.update({ fleet, servers, clanRoster, news }, req.user)
if (!result.ok) {
res.status(result.status || 400).json({ message: result.message })
return
}
// One row per save, naming everything it changed. Widening who may see the
// roll call is exactly the kind of change somebody later needs to trace to a
// person and a time.
await core.activity.log({ req, action: 'rust.visibility.save', detail: result.changed })
res.json(await describe())
} catch (err) {
log.error('failed to save visibility settings', { error: err.message })
res.status(500).json({ message: 'Failed to save the visibility settings' })
}
}
module.exports = { read, update }