Soziales Netz im Spiel: Feed, Werbung, Markt, Kalender und Gewerbe
Jeder Spieler waehlt sich ein Handle mit @, Unternehmen und Behoerden bekommen
eigene Profile, fuer die sie Mitarbeiter freigeben.
Verwaltet wird ueber dieselbe Anmeldung wie das Webhosting: wer am IC-Computer
als Anbieter angemeldet ist, richtet Unternehmensprofile ein. Damit gibt es
genau eine Stelle, an der Verwaltungsrechte haengen - ein zweites Rechtesystem
daneben waere eine zweite Stelle, an der man jemanden zu entziehen vergisst.
Bewusst getrennt: wer fuer ein Unternehmen schreiben darf, kann sich nicht
selbst zum Verwalter machen.
Behoben gegenueber dem Ausgangsstand:
- Die Resource startete nicht. Eine harte Abhaengigkeit zeigte auf eine
Resource, die es nicht gibt - das verhindert den Start vollstaendig.
- Das Schema war gegenueber dem Code stehengeblieben: eine Tabelle fehlte
ganz, sechs Spalten fehlten. Jede Registrierung eines Handles scheiterte
deshalb mit einem SQL-Fehler. Zwei Migrationen ziehen das nach.
- Die Identitaet kommt jetzt von ESX statt von einem Charaktersystem, das
hier nicht laeuft. Ohne das findet das Mailsystem die Postfaecher nicht.
- Das Fenster hatte keinen Schliessknopf, nur ESC. Im Computerfenster ist
diese Taste aber schon vergeben.
- Bilder laden mit referrerpolicy="no-referrer": Bilderdienste sperren
Hotlinks anhand der Herkunft, und die eines NUI kennen sie nicht.
- Der Schluessel fuer den Bilder-Upload steht nicht mehr im Code, sondern in
der server.cfg (set bleeter_imgbb_key). Er gehoert nicht in ein oeffentlich
einsehbares Repository.
Neu: Unternehmensprofile und Mitarbeiterfreigabe, ueber Netzwerkereignisse und
Konsolenbefehle. Dazu eine Oberflaeche im IC-Computer, die dieselbe Gestaltung
benutzt - die Stildatei wird dafuer mechanisch gekapselt, statt sie nachzubauen.
Enthaelt README.md mit Einrichtung, Rechten und den Fallstricken.
This commit is contained in:
commit
20076b0aee
41 changed files with 8652 additions and 0 deletions
62
web-backend/routes/moderation.js
Normal file
62
web-backend/routes/moderation.js
Normal file
|
|
@ -0,0 +1,62 @@
|
|||
const express = require('express');
|
||||
const db = require('../db');
|
||||
const { requireAuth } = require('../auth');
|
||||
const { resolveActingProfile, findTargetProfile } = require('../lib/account');
|
||||
const { hasLifeinvaderPermission, decodeBool } = require('../lib/permissions');
|
||||
|
||||
const router = express.Router();
|
||||
router.use(requireAuth);
|
||||
|
||||
const PERMISSION_BY_ACTION = {
|
||||
verify: 'profile.verify',
|
||||
staff: 'profile.staff',
|
||||
lock: 'profile.lock',
|
||||
};
|
||||
|
||||
async function writeAudit(account, actorProfile, action, targetType, targetId, reason, payload) {
|
||||
await db.insert(
|
||||
`INSERT INTO bleeter_audit_logs (actor_char_id, actor_profile_id, action, target_type, target_id, reason, payload)
|
||||
VALUES (?, ?, ?, ?, ?, ?, ?)`,
|
||||
[account.char_id, actorProfile ? actorProfile.id : null, action, targetType, targetId, reason || null,
|
||||
payload ? JSON.stringify(payload) : null]
|
||||
);
|
||||
}
|
||||
|
||||
// POST /api/moderation/profile {profileId, action: verify|staff|lock, targetId}
|
||||
router.post('/moderation/profile', async (req, res) => {
|
||||
const { profile } = await resolveActingProfile(req.account, req.body.profileId);
|
||||
const action = String(req.body.action || '').trim();
|
||||
const target = await findTargetProfile({ targetId: req.body.targetId }, true);
|
||||
if (!profile || !target) return res.status(400).json({ error: 'invalid' });
|
||||
|
||||
const permission = PERMISSION_BY_ACTION[action];
|
||||
if (!permission || !(await hasLifeinvaderPermission(db, req.account.char_id, permission))) {
|
||||
return res.status(403).json({ error: 'no_lifeinvader_rights' });
|
||||
}
|
||||
if (action === 'lock' && Number(profile.id) === Number(target.id)) {
|
||||
return res.status(400).json({ error: 'cannot_lock_self' });
|
||||
}
|
||||
|
||||
if (action === 'verify') {
|
||||
const next = !decodeBool(target.is_verified);
|
||||
await db.exec('UPDATE bleeter_profiles SET is_verified = ? WHERE id = ?', [next ? 1 : 0, target.id]);
|
||||
await writeAudit(req.account, profile, next ? 'profile.verify' : 'profile.unverify', 'profile', target.id, null, { handle: target.handle, is_verified: next });
|
||||
return res.json({ ok: true, is_verified: next });
|
||||
}
|
||||
if (action === 'staff') {
|
||||
const next = !decodeBool(target.is_lifeinvader_staff);
|
||||
await db.exec('UPDATE bleeter_profiles SET is_lifeinvader_staff = ? WHERE id = ?', [next ? 1 : 0, target.id]);
|
||||
await writeAudit(req.account, profile, next ? 'profile.staff.add' : 'profile.staff.remove', 'profile', target.id, null, { handle: target.handle, is_lifeinvader_staff: next });
|
||||
return res.json({ ok: true, is_lifeinvader_staff: next });
|
||||
}
|
||||
if (action === 'lock') {
|
||||
const next = !decodeBool(target.is_locked);
|
||||
await db.exec('UPDATE bleeter_profiles SET is_locked = ?, locked_reason = ? WHERE id = ?',
|
||||
[next ? 1 : 0, next ? 'Lifeinvader moderation' : null, target.id]);
|
||||
await writeAudit(req.account, profile, next ? 'profile.lock' : 'profile.unlock', 'profile', target.id, null, { handle: target.handle, is_locked: next });
|
||||
return res.json({ ok: true, is_locked: next });
|
||||
}
|
||||
res.status(400).json({ error: 'unknown_action' });
|
||||
});
|
||||
|
||||
module.exports = router;
|
||||
Loading…
Add table
Add a link
Reference in a new issue