From 9efb2558fcced31ecfcd7a72cd3a632ab12012b8 Mon Sep 17 00:00:00 2001 From: Burrowdev Date: Wed, 21 Oct 2026 20:50:44 +0300 Subject: [PATCH] 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 --- lib/modpanel.js | 6 +++--- lib/roles.js | 35 +++++++++++++++++++++++++++++++++-- public/mod.html | 6 +++--- server.js | 2 ++ 4 files changed, 41 insertions(+), 8 deletions(-) diff --git a/lib/modpanel.js b/lib/modpanel.js index 4a02259..2bd8a51 100644 --- a/lib/modpanel.js +++ b/lib/modpanel.js @@ -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 || ""); diff --git a/lib/roles.js b/lib/roles.js index 917c793..9b4fd91 100644 --- a/lib/roles.js +++ b/lib/roles.js @@ -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}; diff --git a/public/mod.html b/public/mod.html index ef93b98..f7a225a 100644 --- a/public/mod.html +++ b/public/mod.html @@ -2057,8 +2057,8 @@ // card, their name opens it) const paintingButtons = (painting, withPlayer) => { const buttons = el("div", undefined, "buttons"); - // judging paintings is for the roles that judge what players make - if (permissions.has("items.approve")) { + // judging paintings is for the roles that may (masterpieces.approve) + if (permissions.has("masterpieces.approve")) { buttons.append(...(painting.status === "waiting" ? [button("Approve", () => judge(painting, true), "primary")] : []), button("Reject", () => judge(painting, false), "danger")); } @@ -3136,7 +3136,7 @@ sub.hidden = !allowed.has(sub.dataset.needs); } // a role that does not judge paintings has approved none of them - $("recent-mine").closest("label").hidden = !allowed.has("items.approve"); + $("recent-mine").closest("label").hidden = !allowed.has("masterpieces.approve"); // the pages the role may see; the first of them when the one open is not. const pages = [...document.querySelectorAll("nav button")]; for (const page of pages) { diff --git a/server.js b/server.js index 02f4bc3..f4a487f 100644 --- a/server.js +++ b/server.js @@ -8,6 +8,7 @@ const bans = require("./lib/bans.js"); const devices = require("./lib/devices.js"); const discord = require("./lib/discord.js"); const discordBot = require("./lib/discordbot.js"); +const roles = require("./lib/roles.js"); const chatlog = require("./lib/chatlog.js"); const modlog = require("./lib/modlog.js"); const retention = require("./lib/retention.js"); @@ -54,6 +55,7 @@ const main = async () => { masterpieces.load(); retention.load(); stats.load(() => world.players().length); + roles.load(); panel.load(); await http.start(); await sfs.start(world);