mirror of
https://github.com/burrow-dev/burrow-server.git
synced 2026-11-18 17:27:50 -05:00
feat(roles): masterpieces.approve, its own permission
Approving and removing framed paintings was items.approve, which also judges the items and pictures players make. masterpieces.approve now guards it, on the server (POST /mod/api/masterpiece) and in the mod panel's buttons and its "only ones I approved" filter. Moderators and admins have it by default; seeing the Masterpieces page is still player.view. roles.load, once at start (setting permissionSplitMasterpieces): a role list the admin changed, and a staff member's own grants and denies, that held items.approve are given masterpieces.approve too, so nobody gains or loses anything by the split. Co-Authored-By: Claude Opus 5.5 <[email protected]>
This commit is contained in:
1 parent
9720d309fa
commit
9efb2558fc
4 files changed
+41
-8
No files matched your search
+3
-3
@@ -896,10 +896,10 @@ const handle = async (req, res, url, from, web) => {
|
||||
return;
|
||||
}
|
||||
|
||||
// a painting judged: for the roles that judge what players make, and
|
||||
// never their own or one by staff of their rank or above.
|
||||
// a painting judged: for the roles that judge paintings, and never
|
||||
// their own or one by staff of their rank or above.
|
||||
case "POST /mod/api/masterpiece": {
|
||||
if (!may("items.approve")) {
|
||||
if (!may("masterpieces.approve")) {
|
||||
return;
|
||||
}
|
||||
const id = String(body.id || "");
|
||||
|
||||
+33
-2
@@ -29,6 +29,7 @@ const PERMISSIONS = {
|
||||
"player.names": "reject or accept a name, answer requests for a new one, clear a bio, remove a player's Jammer Wall posts",
|
||||
"address.ban": "ban the address a player last signed in from, or the computers they use, and lift those bans",
|
||||
"items.approve": "approve or turn away the items and pictures players make, when the admin has asked for that",
|
||||
"masterpieces.approve": "approve or remove the paintings players frame as masterpieces (the Masterpieces page)",
|
||||
"items.restrict": "stop a clothing item from being worn by selected animal types",
|
||||
"items.create": "make new items from the game's art, change and delete them, lock items out of the item finder and take items from players (!item, !lock, !unlock, !locked, !take)",
|
||||
"room.effects": "run temporary room-wide size and colour effects (!roomfx)",
|
||||
@@ -38,7 +39,7 @@ const PERMISSIONS = {
|
||||
};
|
||||
|
||||
const HELPER = ["server.view", "player.view", "staff.list", "player.warn", "player.goto", "chat.silence"];
|
||||
const MODERATOR = [...HELPER, "player.kick", "player.summon", "staff.invisible", "player.ban", "player.names", "address.ban", "items.approve", "items.restrict", "theater.control", "staff.log"];
|
||||
const MODERATOR = [...HELPER, "player.kick", "player.summon", "staff.invisible", "player.ban", "player.names", "address.ban", "items.approve", "masterpieces.approve", "items.restrict", "theater.control", "staff.log"];
|
||||
const ADMIN = [...MODERATOR, "server.announce", "items.create", "room.effects", "music.upload"];
|
||||
// a developer makes things, and moderates nobody.
|
||||
const DEVELOPER = ["server.view", "staff.list", "items.create", "room.effects", "theater.control"];
|
||||
@@ -119,6 +120,36 @@ const setRolePermissions = (role, list) => {
|
||||
return true;
|
||||
};
|
||||
|
||||
// masterpieces.approve was split from items.approve (2026-10-21), which
|
||||
// judged paintings before. once: a role list the admin changed, and a staff
|
||||
// member's own grants and denies, that held items.approve hold this too.
|
||||
const SPLIT_SETTING = "permissionSplitMasterpieces";
|
||||
const load = () => {
|
||||
if (accounts.setting(SPLIT_SETTING)) {
|
||||
return;
|
||||
}
|
||||
const withSplit = list => (Array.isArray(list) && list.includes("items.approve") && !list.includes("masterpieces.approve")
|
||||
? [...list, "masterpieces.approve"] : list);
|
||||
const changed = {...overrides()};
|
||||
for (const role of Object.keys(changed)) {
|
||||
changed[role] = withSplit(changed[role]);
|
||||
}
|
||||
accounts.setSetting(ROLE_SETTING, JSON.stringify(changed));
|
||||
roleOverrides = changed;
|
||||
for (const account of accounts.all()) {
|
||||
if (account.permGrants || account.permDenies) {
|
||||
const grants = withSplit(account.permGrants);
|
||||
const denies = withSplit(account.permDenies);
|
||||
if (grants !== account.permGrants || denies !== account.permDenies) {
|
||||
if (grants) account.permGrants = grants;
|
||||
if (denies) account.permDenies = denies;
|
||||
accounts.save(account);
|
||||
}
|
||||
}
|
||||
}
|
||||
accounts.setSetting(SPLIT_SETTING, "1");
|
||||
};
|
||||
|
||||
const permissionsOf = account => {
|
||||
const role = roleOf(account);
|
||||
if (!role) {
|
||||
@@ -170,5 +201,5 @@ const setRole = (account, role) => {
|
||||
return true;
|
||||
};
|
||||
|
||||
module.exports = {PERMISSIONS, ROLES, roleOf, rankOf, isActiveStaff, permissionsOf, rolePermissions, roleChanged, setRolePermissions,
|
||||
module.exports = {load, PERMISSIONS, ROLES, roleOf, rankOf, isActiveStaff, permissionsOf, rolePermissions, roleChanged, setRolePermissions,
|
||||
setAccountPermissions, can, outranks, setRole};
|
||||
Reference in new issue
Block a user