// ── Admin · Rust · Visibility ───────────────────────────────────────────── // // Mounted under the admin tier's `/rust` prefix, so every path here is // `/api/v1/admin/rust/visibility`. Who may see what the servers say about the // people on them — a fourth subject beside the bridge, the permissions and the // mod configuration. // // **Every route is `requireRole('admin')`.** The tier's own gate admits editors // and moderators, and a moderator widening the roll call to the public is the // decision the org lead settled should be deliberate. Reading is gated the same // as writing: the screen is one form, and a view of the settings without the // power to change them is not something anybody has asked for. const core = require('../../core') const express = core.express const visibility = require('./visibility.controller') const { requireRole, validate } = core.middleware const { body } = core.validator const visibilityRouter = express.Router() const AUDIENCES = ['staff', 'signed_in', 'public'] const CLAN_AUDIENCES = ['members', 'signed_in', 'public'] visibilityRouter.get( '/', // #swagger.tags = ['Admin · Rust'] // #swagger.summary = 'Who may see who is online, and who may see a clan roster' // #swagger.description = 'The presence fleet default and every server’s optional override. It governs the Online list, every feed item that names a player who was on the server (connects, respawns, deaths, chat, tallies) and the leaderboard’s `lastSeen`. The default is `staff`: nothing names who is online until an operator widens it. The player count is public at every setting. `clans` carries the clan roster audience (default `members`: the clan’s own linked members, and staff) and each server’s clan board — whether it is current, at the game’s 100-clan ceiling, or running the uMod Clans plugin, whose clans are not Teams.' /* #swagger.responses[200] = { description: 'The fleet default and each server', content: { "application/json": { schema: { $ref: "#/components/schemas/RustVisibility" } } } } */ requireRole('admin'), visibility.read, ) visibilityRouter.put( '/', // #swagger.tags = ['Admin · Rust'] // #swagger.summary = 'Change who may see who is online, or who may see a clan roster' // #swagger.description = 'Sets the presence fleet default, one or more server overrides, the clan roster audience, or any of them together. A server set to `null` follows the fleet default again. Validated whole before anything is written: a request naming a server that does not exist changes nothing. Widening the clan roster audience also shows which members are online to that audience, because a roster row carries it.' /* #swagger.requestBody = { required: true, content: { "application/json": { schema: { $ref: "#/components/schemas/RustVisibilityUpdate" } } } } */ /* #swagger.responses[200] = { description: 'Saved; answers the new state', content: { "application/json": { schema: { $ref: "#/components/schemas/RustVisibility" } } } } */ /* #swagger.responses[400] = { description: 'An audience that does not exist' } */ /* #swagger.responses[404] = { description: 'A server that does not exist' } */ requireRole('admin'), body('fleet').optional().isIn(AUDIENCES).withMessage(`fleet must be one of ${AUDIENCES.join(', ')}`), body('servers').optional().isObject().withMessage('servers maps a server id to an audience or null'), body('clanRoster').optional().isIn(CLAN_AUDIENCES).withMessage(`clanRoster must be one of ${CLAN_AUDIENCES.join(', ')}`), validate, visibility.update, ) module.exports = visibilityRouter