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;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
// a painting judged: for the roles that judge what players make, and
|
// a painting judged: for the roles that judge paintings, and never
|
||||||
// never their own or one by staff of their rank or above.
|
// their own or one by staff of their rank or above.
|
||||||
case "POST /mod/api/masterpiece": {
|
case "POST /mod/api/masterpiece": {
|
||||||
if (!may("items.approve")) {
|
if (!may("masterpieces.approve")) {
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
const id = String(body.id || "");
|
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",
|
"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",
|
"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",
|
"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.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)",
|
"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)",
|
"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 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"];
|
const ADMIN = [...MODERATOR, "server.announce", "items.create", "room.effects", "music.upload"];
|
||||||
// a developer makes things, and moderates nobody.
|
// a developer makes things, and moderates nobody.
|
||||||
const DEVELOPER = ["server.view", "staff.list", "items.create", "room.effects", "theater.control"];
|
const DEVELOPER = ["server.view", "staff.list", "items.create", "room.effects", "theater.control"];
|
||||||
@@ -119,6 +120,36 @@ const setRolePermissions = (role, list) => {
|
|||||||
return true;
|
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 permissionsOf = account => {
|
||||||
const role = roleOf(account);
|
const role = roleOf(account);
|
||||||
if (!role) {
|
if (!role) {
|
||||||
@@ -170,5 +201,5 @@ const setRole = (account, role) => {
|
|||||||
return true;
|
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};
|
setAccountPermissions, can, outranks, setRole};
|
||||||
+3
-3
@@ -2057,8 +2057,8 @@
|
|||||||
// card, their name opens it)
|
// card, their name opens it)
|
||||||
const paintingButtons = (painting, withPlayer) => {
|
const paintingButtons = (painting, withPlayer) => {
|
||||||
const buttons = el("div", undefined, "buttons");
|
const buttons = el("div", undefined, "buttons");
|
||||||
// judging paintings is for the roles that judge what players make
|
// judging paintings is for the roles that may (masterpieces.approve)
|
||||||
if (permissions.has("items.approve")) {
|
if (permissions.has("masterpieces.approve")) {
|
||||||
buttons.append(...(painting.status === "waiting" ? [button("Approve", () => judge(painting, true), "primary")] : []),
|
buttons.append(...(painting.status === "waiting" ? [button("Approve", () => judge(painting, true), "primary")] : []),
|
||||||
button("Reject", () => judge(painting, false), "danger"));
|
button("Reject", () => judge(painting, false), "danger"));
|
||||||
}
|
}
|
||||||
@@ -3136,7 +3136,7 @@
|
|||||||
sub.hidden = !allowed.has(sub.dataset.needs);
|
sub.hidden = !allowed.has(sub.dataset.needs);
|
||||||
}
|
}
|
||||||
// a role that does not judge paintings has approved none of them
|
// 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.
|
// the pages the role may see; the first of them when the one open is not.
|
||||||
const pages = [...document.querySelectorAll("nav button")];
|
const pages = [...document.querySelectorAll("nav button")];
|
||||||
for (const page of pages) {
|
for (const page of pages) {
|
||||||
|
|||||||
@@ -8,6 +8,7 @@ const bans = require("./lib/bans.js");
|
|||||||
const devices = require("./lib/devices.js");
|
const devices = require("./lib/devices.js");
|
||||||
const discord = require("./lib/discord.js");
|
const discord = require("./lib/discord.js");
|
||||||
const discordBot = require("./lib/discordbot.js");
|
const discordBot = require("./lib/discordbot.js");
|
||||||
|
const roles = require("./lib/roles.js");
|
||||||
const chatlog = require("./lib/chatlog.js");
|
const chatlog = require("./lib/chatlog.js");
|
||||||
const modlog = require("./lib/modlog.js");
|
const modlog = require("./lib/modlog.js");
|
||||||
const retention = require("./lib/retention.js");
|
const retention = require("./lib/retention.js");
|
||||||
@@ -54,6 +55,7 @@ const main = async () => {
|
|||||||
masterpieces.load();
|
masterpieces.load();
|
||||||
retention.load();
|
retention.load();
|
||||||
stats.load(() => world.players().length);
|
stats.load(() => world.players().length);
|
||||||
|
roles.load();
|
||||||
panel.load();
|
panel.load();
|
||||||
await http.start();
|
await http.start();
|
||||||
await sfs.start(world);
|
await sfs.start(world);
|
||||||
|
|||||||
Reference in new issue
Block a user