// ── Admin · Rust · Visibility — the handlers ────────────────────────────── const core = require('../../core') const visibility = require('../../model/visibility/visibility.model') const log = core.logger('visibility') async function read(req, res) { try { res.json(await visibility.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 } = req.body || {} const result = await visibility.update({ fleet, servers }, 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 visibility.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 }