Files
Module-Rust/server/router/admin/zones.controller.js
wtclaude 8361b19c24 feat(rust): zone presets, and the zone step's options, messages and dome (PLAN_REDESIGNS §3, D210)
Admin → Rust zone presets: named sets of ZoneManager flags and settings for
one server, several, or every server (D195), ticked in groups read from each
server's own ZoneManager list in its last hello (D211). A flag not on a
covered server is refused on save with the server named; two presets of one
name may not share a server.

rust.zone.open gains options (one line, NoBuild, radiation=10), enterMessage,
leaveMessage, delivery, dome and domeStack. The options field's dropdown is
rust.options.zone_presets, whose row VALUE is the preset's line, so picking
one copies it into the step (D210) and no published event changes when a
preset does. The line and the dome are checked against the server's hello
on save and in a dry run; bad-option and dome-unavailable are permanent.

Schema: rust_zone_presets, rust_zone_preset_servers. Swagger fragment and
routes.manifest regenerated against the pinned core f0e7d2a.

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

57 lines
1.8 KiB
JavaScript

// ── Admin · Rust · Zone presets — the handlers ────────────────────────────
const core = require('../../core')
const zones = require('../../model/zones/zones.model')
const log = core.logger('zones')
const by = (req) => (req.user ? req.user.id : null)
/** A model refusal answers with its own status; anything else is ours to log. */
function fail(res, err, what) {
if (err instanceof zones.ZonePresetError) return res.status(err.status).json({ message: err.message })
log.error(`failed to ${what}`, { error: err.message })
return res.status(500).json({ message: `Failed to ${what}` })
}
async function describe(req, res) {
try {
res.json(await zones.describe())
} catch (err) {
fail(res, err, 'read the zone presets')
}
}
async function create(req, res) {
try {
const preset = await zones.create(req.body || {}, by(req))
await core.activity.log({ req, action: 'rust.zones.preset.create', detail: { id: preset.id, name: preset.name } })
res.status(201).json(preset)
} catch (err) {
fail(res, err, 'save the zone preset')
}
}
async function update(req, res) {
try {
const preset = await zones.update(Number(req.params.id), req.body || {})
await core.activity.log({ req, action: 'rust.zones.preset.update', detail: { id: preset.id, name: preset.name } })
res.json(preset)
} catch (err) {
fail(res, err, 'save the zone preset')
}
}
async function remove(req, res) {
try {
await zones.remove(Number(req.params.id))
await core.activity.log({ req, action: 'rust.zones.preset.delete', detail: { id: Number(req.params.id) } })
res.json({ ok: true })
} catch (err) {
fail(res, err, 'delete the zone preset')
}
}
module.exports = { describe, create, update, remove }