mirror of
https://github.com/burrow-dev/burrow-server.git
synced 2026-11-19 01:27:51 -05:00
Staff roles with permissions, warnings, in-game staff commands
Moderators were one flag on the account. Now an account can hold a staff
role (lib/roles.js): helper, moderator or admin, each a list of named
permissions, with a higher role holding everything below it. An account
only marked `moderator` still counts as a moderator.
Every staff action checks the permission it needs, and staff never act
on staff of their own rank or above:
- warnings: kept on the account (who, when, the reason, a note for
staff), and shown to the player with the game's own warning popup for
the reason ("fw": inappropriate behavior, bullying, personal
information, scamming), which this server's strings already word as the
Burrow Rules.
- moderator panel: each action is checked against the role; new actions
"warn" (with a reason and note), "summon" (bring a player to the room you
are in) and "goto"; the player's page shows their warnings; GET
/mod/api/me returns your role and permissions, and the page hides the
buttons yours does not allow.
- in the game: !staff, !summon, !goto, !kick, !silence (HOURS, 0, or
off), !warn PLAYER [reason] [note], !warnings PLAYER and !message, for
staff whose role allows each, written to the moderators' log like the
panel's actions, marked "(in game)". To anyone else they are plain chat.
Usernames with spaces work.
- the login reply carries the player's own staffRole and
staffPermissions (empty for everyone else), so a client can show staff
tools only to staff.
- admin panel: a role picker on the account, "role" on POST
/admin/api/account, and GET /admin/api/roles listing what each allows.
The old moderator switch still works.
Also: the moderators' message box showed "--Message From Moderator--\n\n"
with the "\n" as written (strings 11134 and 11135 keep it as two
characters); they get real line breaks.
Staff powers need 2FA turned on, as the moderator panel already did. In
the game they come with the game session, which a trusted device opens
without a code; requiring a recent code there is left for later.
test/staff.js covers all of the above end to end.
Co-Authored-By: Claude Opus 5.5 <[email protected]>
This commit is contained in:
1 parent
63dc43ebb3
commit
2fba9f1612
10 files changed
+756
-21
No files matched your search
@@ -5,6 +5,7 @@ const achievements = require("./achievements.js");
|
||||
const adopt = require("./adopt.js");
|
||||
const config = require("../config.js");
|
||||
const colours = require("./colours.js");
|
||||
const roles = require("./roles.js");
|
||||
const commandModule = require("./commands.js");
|
||||
const limits = require("./limits.js");
|
||||
const masterpieces = require("./masterpieces.js");
|
||||
@@ -185,6 +186,11 @@ const loginParams = session => {
|
||||
// from bit 8 up: the name tag badges the admin gave this account
|
||||
// (lib/badges.js).
|
||||
pendingFlags: 7 | badges.loginFlags(account),
|
||||
// this account's own staff role and what it allows (lib/roles.js), for a
|
||||
// client to show staff tools only to staff. empty for everyone else, and
|
||||
// only ever about the account logging in.
|
||||
staffRole: roles.isActiveStaff(account) ? roles.roleOf(account) : "",
|
||||
staffPermissions: roles.isActiveStaff(account) ? roles.permissionsOf(account).join(",") : "",
|
||||
dailyGiftIndex: -1,
|
||||
hasOnlineBuddies: buddies.hasOnlineBuddies(account),
|
||||
// one bit per kind of interaction (Utility.canBuddy, canTrade, canGift,
|
||||
@@ -896,6 +902,31 @@ const fileReport = (session, username, reason, detail = "", about = "") => {
|
||||
|
||||
// what the modules below may use of this one. `others` here is everyone who
|
||||
// should see the player's animal change; dens get everyone in the room.
|
||||
// staff moving a player: `whoName` to the room `toName` is in (summon is
|
||||
// the player to the staff member, goto the staff member to the player). both
|
||||
// online, `toName` in a room. the room's own rules still apply: a full room
|
||||
// or a locked den keeps them out.
|
||||
const staffMove = (whoName, toName) => {
|
||||
const who = findOnline(whoName);
|
||||
const to = findOnline(toName);
|
||||
if (!who) {
|
||||
return {error: `${whoName} is not online.`};
|
||||
}
|
||||
if (!to || !to.room) {
|
||||
return {error: `${toName} is not in a room.`};
|
||||
}
|
||||
const room = to.room;
|
||||
const shown = room.displayName || room.name;
|
||||
if (who.room === room) {
|
||||
return {error: "Already in the same room."};
|
||||
}
|
||||
if (room.sessions.size >= config.maxUsersPerRoom) {
|
||||
return {error: `${shown} is full.`};
|
||||
}
|
||||
joinRoom(who, room.name);
|
||||
return who.room === room ? {ok: true, room: shown} : {error: `Could not get into ${shown}.`};
|
||||
};
|
||||
|
||||
const context = {
|
||||
others: watchers,
|
||||
watchers,
|
||||
@@ -917,6 +948,9 @@ const context = {
|
||||
ask: (...args) => ask(...args),
|
||||
travel: (session, base) => joinRoom(session, `${base}#${config.shards[0].id}`),
|
||||
joinRoom: (...args) => joinRoom(...args),
|
||||
staffMove: (...args) => staffMove(...args),
|
||||
// the moderation module, made after this context (lib/commands.js uses it)
|
||||
staffModeration: () => moderation,
|
||||
reloadRoom: session => reloadRoom(session),
|
||||
buyAgain: session => handlers[session.lastPurchase.cmd](session, session.lastPurchase.roomId, session.lastPurchase.params),
|
||||
};
|
||||
@@ -1429,6 +1463,7 @@ module.exports = {
|
||||
return true;
|
||||
},
|
||||
moderation,
|
||||
staffMove,
|
||||
walls,
|
||||
ecards,
|
||||
// called when the admin changed an account's badges: a name tag showing
|
||||
|
||||
Reference in new issue
Block a user