mirror of
https://github.com/burrow-dev/burrow-server.git
synced 2026-11-19 01:27:51 -05:00
feat(server): staff tools, player-made items, picture safety, chat, multiplayer games
Staff and moderation
- Invisible staff (!invisible, "xiv"): hidden from players, half see-through
to other staff, cannot chat while hidden. New permission staff.invisible.
- Summon and goto land on the player's exact spot ("xgt" before the move).
- Custom warnings (!warn PLAYER custom TEXT), shown in the warning popup.
- Mod notes (!note, !notes; lib/modnotes.js), on the player page and the
dashboard.
- Granular permissions: per-role overrides (setting rolePermissions) and
per-account grants and denies, applied live to staff who are playing
(refreshStaff re-sends "xsp").
- Item control (lib/itemcontrol.js): lock items out of the item finder
(!lock, !unlock, !locked), take an item from a player (!take), delete a
custom item from the game and every inventory.
- GET items/find: search any item by name or id, marked locked, for the
dashboards' quick lock.
Player-made items (lib/playeritems.js, "xcm")
- The Item Maker: make, rename, set the worn look, delete. 5 a day, 20 in all;
names go through the name filter.
- Admin switches: Item Maker on/off, new items wait for approval, and a
separate switch (on by default) that holds every player-uploaded picture
for a moderator. Review queue for items.approve (moderator and up).
- Pictures (lib/itemart.js): PNG, JPEG and GIF cleaned of metadata, BMP
converted to PNG; 512px and 300KB at most once cleaned.
- Worn as the maker chooses: a sticker (the picture) or a texture (the
item's shape painted with the picture).
Picture safety
- A picture waiting for approval is never served publicly: /itemart/ 404s it,
and it is only shown through /account|/mod|/admin/api/itemart to its maker
and to staff who review or make items.
- A picture turned away or taken off is remembered by SHA-256 and cannot be
uploaded again.
- Three strikes: three pictures turned away stops a player's uploads until a
moderator lets them again. Staff can stop or allow uploads by hand.
- Accounts under 24 hours old cannot upload pictures (AJ_ITEM_ART_MIN_HOURS);
uploads capped at 10 a day.
- Optional Google Cloud Vision SafeSearch (lib/image-moderation.js) for item
pictures and Art Studio paintings when AJ_GOOGLE_VISION_API_KEY is set;
fails closed when the scanner is unreachable.
Chat
- Emoji: Twemoji pictures served at /emoji/<codepoints>.png and cached in
data/emoji (lib/emoji.js).
- Smart spam filtering before the word filter (lib/chatspam.js): long runs of
one character, repeated words and lines, huge words and emoji floods are
tidied, and repeats within 20 seconds are dropped.
- Typing indicator: "xty" is passed on to everyone in the room who can see
the player, at most every 2 seconds.
Games (lib/minigames.js)
- Room games can be played together: a MULTIPLAYER table gives a game a
waiting list (Single Player / Multiplayer). Players in the same room are
matched, taken into the game together, and each one's moves are relayed to
the others. Gem Breaker is the first: two players, "pos", "shoot" and
"playerLost" relayed.
- Gem Breaker's start message now lists each player's id. Without it no
player counted as local, so even single player could not aim.
Other
- Players stay connected through the client's new 75-minute AFK limit
(idleTimeoutMs 80 minutes).
- Jam-a-Grams carry custom items and colours; Jammer Wall avatar photos are
validated (walls.js photoParam).
- Weak passwords refused (common words, or containing the username).
- Code-scanning fixes: every logged value goes through logText
(lib/logtext.js) against log injection, HSTS, path-only error logs, a
single file read in lib/names.js.
Tests: items (pictures, approval, strikes, re-upload refusal, the hidden
waiting picture, the dashboard search), staff (invisibility, goto and summon
spots, custom warnings, notes), buddygames (two-player Gem Breaker, the
typing relay), and updates for main's verified badge and spawn rooms.
Co-Authored-By: Claude Opus 5.5 <[email protected]>
This commit is contained in:
1 parent
da7eb9af58
commit
e05565787f
50 files changed
+2904
-277
No files matched your search
+152
-13
@@ -4,17 +4,22 @@ const crypto = require("crypto");
|
||||
const fs = require("fs");
|
||||
const path = require("path");
|
||||
const accounts = require("./accounts.js");
|
||||
const admin = require("./admin.js");
|
||||
const bans = require("./bans.js");
|
||||
const captcha = require("./captcha.js");
|
||||
const chatlog = require("./chatlog.js");
|
||||
const config = require("../config.js");
|
||||
const customItems = require("./customitems.js");
|
||||
const itemControl = require("./itemcontrol.js");
|
||||
const itemArt = require("./itemart.js");
|
||||
const playerItems = require("./playeritems.js");
|
||||
const defpacks = require("./defpacks.js");
|
||||
const devices = require("./devices.js");
|
||||
const limits = require("./limits.js");
|
||||
const manage = require("./manage.js");
|
||||
const masterpieces = require("./masterpieces.js");
|
||||
const modlog = require("./modlog.js");
|
||||
const modNotes = require("./modnotes.js");
|
||||
const reports = require("./reports.js");
|
||||
const roles = require("./roles.js");
|
||||
const staff = require("./staff.js");
|
||||
@@ -49,6 +54,7 @@ const SESSION_HOURS = 12;
|
||||
const TEN_MINUTES_MS = 600000;
|
||||
const MAX_BAN_HOURS = 24 * 365 * 10;
|
||||
const MAX_MESSAGE_LENGTH = 200;
|
||||
const MAX_RECENT_NOTES = 15;
|
||||
|
||||
const failuresByAddress = limits.limiter(config.failedLoginsPerTenMinutes, TEN_MINUTES_MS);
|
||||
const actionsPerTenMinutes = limits.limiter(300, TEN_MINUTES_MS); // per moderator
|
||||
@@ -124,10 +130,16 @@ const playerDetail = account => ({
|
||||
history: bans.historyOf(account).map(({at, action, seconds, reason, by}) => ({at, action, seconds, reason, by})),
|
||||
appeal: bans.appealOf(account),
|
||||
warningList: (account.warnings || []).slice(-20).reverse(),
|
||||
notes: modNotes.list(account),
|
||||
openReports: reports.list(false).filter(report => report.target.toLowerCase() === account.username.toLowerCase()).length,
|
||||
devicesKnown: devices.knownFor(account).ids,
|
||||
stoppedThisWeek: chatlog.notSentCount(account, 7),
|
||||
paintings: masterpieces.madeBy(account).length,
|
||||
// what they made in the Item Maker, with its pictures, for a report about one
|
||||
madeItems: playerItems.madeBy(account).map(entry => ({kind: entry.kind, id: entry.id, name: entry.name,
|
||||
artUrl: itemArt.urlOf(entry, "/mod/api/itemart"), artWaiting: Boolean(entry.artPending)})),
|
||||
picturesStopped: Boolean(account.artBlocked),
|
||||
pictureStrikes: account.artRefusals || 0,
|
||||
});
|
||||
|
||||
// an address with its end left out, and a name to lift its ban by.
|
||||
@@ -149,6 +161,7 @@ const ACTION_PERMISSIONS = {
|
||||
rejectName: "player.names", acceptName: "player.names", clearBio: "player.names",
|
||||
banAddress: "address.ban",
|
||||
summon: "player.summon", goto: "player.goto",
|
||||
note: "player.view", deleteNote: "player.view",
|
||||
};
|
||||
|
||||
// minutes as a person would say them: "1 hour", "1 day", "90 minutes".
|
||||
@@ -214,7 +227,8 @@ const act = (mod, target, body) => {
|
||||
const reason = String(body.reason || "behavior");
|
||||
const result = actions.warn(target, reason, by, body.note);
|
||||
if (!result) {
|
||||
return {error: `A warning's reason: ${world.moderation.WARNINGS.join(", ")}.`};
|
||||
return {error: reason === "custom" ? "A custom warning needs its words in the note: they are what the player is shown."
|
||||
: `A warning's reason: ${world.moderation.WARNINGS.join(", ")}.`};
|
||||
}
|
||||
return {ok: `${name} warned (${reason}): warning ${result.count}.${result.online ? "" : " They are offline: they will see it when they next play."}`
|
||||
+ (result.silencedMinutes ? ` That many warnings also silenced them for ${silenceText(result.silencedMinutes)}.` : ""),
|
||||
@@ -242,6 +256,15 @@ const act = (mod, target, body) => {
|
||||
target.bio = "";
|
||||
accounts.save(target);
|
||||
return {ok: "Bio cleared."};
|
||||
// a note for the other staff (lib/modnotes.js); the player never sees it.
|
||||
case "note": {
|
||||
const result = modNotes.add(target, by, body.text);
|
||||
return result.error ? result : {ok: "Note added.", detail: result.note.text};
|
||||
}
|
||||
case "deleteNote": {
|
||||
const result = modNotes.remove(target, body.id, by, roles.roleOf(mod) === "admin");
|
||||
return result.error ? result : {ok: "Note removed.", detail: `${result.note.by}: ${result.note.text}`};
|
||||
}
|
||||
// the address they last signed in from, for good. which address that
|
||||
// is, the moderator is not told.
|
||||
case "banAddress": {
|
||||
@@ -398,13 +421,26 @@ const handle = async (req, res, url, from, web) => {
|
||||
return;
|
||||
}
|
||||
|
||||
// what players made that waits for approval (lib/playeritems.js)
|
||||
if (url.pathname === "/mod/api/review") {
|
||||
if (!roles.can(mod, "items.approve")) {
|
||||
reply(403, {error: "Your role does not allow that."});
|
||||
return;
|
||||
}
|
||||
reviewRoutes(route.replace(" /mod/api/", " "), body, reply, done, mod.username, "/mod/api/itemart");
|
||||
return;
|
||||
}
|
||||
// custom items (lib/customitems.js), for whoever may make them.
|
||||
if (url.pathname.startsWith("/mod/api/items")) {
|
||||
if (!roles.can(mod, "items.create")) {
|
||||
reply(403, {error: "Your role does not allow that."});
|
||||
return;
|
||||
}
|
||||
itemRoutes(route, url, body, reply, done, mod);
|
||||
itemRoutes(route.replace(" /mod/api/", " "), url, body, reply, done, {
|
||||
username: mod.username,
|
||||
artBase: "/mod/api/itemart",
|
||||
mayTake: target => target === mod || !roles.roleOf(target) || roles.outranks(mod, target),
|
||||
});
|
||||
return;
|
||||
}
|
||||
// everything else shows players and what they did: not for a role that
|
||||
@@ -474,6 +510,11 @@ const handle = async (req, res, url, from, web) => {
|
||||
return;
|
||||
}
|
||||
|
||||
// the latest mod notes on anybody (lib/modnotes.js), for the dashboard.
|
||||
case "GET /mod/api/notes":
|
||||
reply(200, {notes: modNotes.recent(MAX_RECENT_NOTES)});
|
||||
return;
|
||||
|
||||
case "GET /mod/api/stats":
|
||||
reply(200, stats.report(Number(url.searchParams.get("days")), Number(url.searchParams.get("offset"))));
|
||||
return;
|
||||
@@ -593,17 +634,39 @@ const handle = async (req, res, url, from, web) => {
|
||||
}
|
||||
};
|
||||
|
||||
// GET /mod/api/items: the custom items, the newest first.
|
||||
// GET /mod/api/items/base?kind=clothing|den&id=N: an item of the game's to
|
||||
// the custom items' pages, for the moderator panel (/mod/api/...) and the
|
||||
// admin panel (/admin/api/..., lib/panel.js): `route` is without that
|
||||
// ("GET items"), and `actor` is {username, mayTake(account)}: who it is
|
||||
// written down as, and whether they may take items from that player.
|
||||
// GET items: the custom items, the newest first.
|
||||
// GET items/find?q=WORDS&kind=all|clothing|den: any item (the game's or a
|
||||
// custom one), by name or id, as the item finder finds it, each marked
|
||||
// whether it is locked out of the finder: for the dashboards' lock.
|
||||
// GET items/base?kind=clothing|den&id=N: an item of the game's to
|
||||
// make one from (its name and colours), to check before making it.
|
||||
// POST /mod/api/items {action: "create", kind, base, name, cost, members, colors}
|
||||
// or {action: "update", kind, id, and any of name, cost, members, colors, inShop}.
|
||||
const itemRoutes = (route, url, body, reply, done, mod) => {
|
||||
// POST items {action: "create", kind, base, name, cost, members, colors}
|
||||
// or {action: "update", kind, id, and any of name, cost, members, colors, inShop}
|
||||
// or {action: "lock" | "unlock", kind, id}: kept out of the item finder
|
||||
// or {action: "take", username, kind, id}: every one of it, from one player
|
||||
// or {action: "delete", kind, id}: a custom item, out of the game and every inventory.
|
||||
const itemRoutes = (route, url, body, reply, done, actor) => {
|
||||
switch (route) {
|
||||
case "GET /mod/api/items":
|
||||
reply(200, {items: customItems.list().map(entry => ({...entry, baseName: customItems.baseName(entry)})), firstId: customItems.FIRST_ID});
|
||||
case "GET items":
|
||||
reply(200, {items: customItems.list().map(entry => ({...entry, baseName: customItems.baseName(entry), locked: itemControl.isLocked(entry.kind, entry.id),
|
||||
artUrl: itemArt.urlOf(entry, actor.artBase)})),
|
||||
firstId: customItems.FIRST_ID, locked: itemControl.lockedList()});
|
||||
return;
|
||||
case "GET /mod/api/items/base": {
|
||||
case "GET items/find": {
|
||||
const found = admin.search(url.searchParams, null, true);
|
||||
reply(200, {total: found.total, results: found.results.slice(0, 20).map(entry => ({
|
||||
kind: entry.kind, id: entry.id, cost: entry.cost,
|
||||
name: entry.locked ? entry.name.replace(/ \(locked\)$/, "") : entry.name,
|
||||
locked: Boolean(entry.locked),
|
||||
custom: entry.id >= customItems.FIRST_ID,
|
||||
})), lockedCount: itemControl.lockedList().length});
|
||||
return;
|
||||
}
|
||||
case "GET items/base": {
|
||||
const kind = url.searchParams.get("kind") === "den" ? "den" : "clothing";
|
||||
const id = Number(url.searchParams.get("id"));
|
||||
const def = kind === "den" ? defpacks.denItemDef(id) : defpacks.itemDef(id);
|
||||
@@ -616,11 +679,37 @@ const itemRoutes = (route, url, body, reply, done, mod) => {
|
||||
: {kind, id, name: defpacks.string(def.titleStrId), art: Number(def.layerDefId), cost: Number(def.value), colors: String(def.colors).split(",").map(Number)});
|
||||
return;
|
||||
}
|
||||
case "POST /mod/api/items": {
|
||||
case "POST items": {
|
||||
const kind = String(body.kind || "");
|
||||
if (body.action === "lock" || body.action === "unlock") {
|
||||
const result = itemControl.setLocked(kind, body.id, body.action === "lock");
|
||||
done(result, result.ok ? `item ${body.action}ed` : "", "", `${kind} ${body.id}`);
|
||||
return;
|
||||
}
|
||||
if (body.action === "take") {
|
||||
const target = accounts.byName(String(body.username || "").trim());
|
||||
if (target && !actor.mayTake(target)) {
|
||||
done({error: "Staff of your rank or above are for someone higher up to deal with."});
|
||||
return;
|
||||
}
|
||||
const result = itemControl.take(String(body.username || "").trim(), kind, body.id, world);
|
||||
done(result, result.ok ? "item taken" : "", target ? target.username : "", `${kind} ${body.id}${result.count ? ` x${result.count}` : ""}`);
|
||||
return;
|
||||
}
|
||||
if (body.action === "look") {
|
||||
const result = customItems.setArtMode(kind, body.id, String(body.look));
|
||||
done(result.error ? result : {ok: `${result.item.name} is worn as ${body.look === "texture" ? "a texture" : "a sticker"}.`},
|
||||
"item look changed", "", `${kind} ${body.id} ${body.look}`);
|
||||
return;
|
||||
}
|
||||
if (body.action === "delete") {
|
||||
const result = itemControl.deleteCustom(kind, body.id, world);
|
||||
done(result, result.ok ? "item deleted" : "", "", `${kind} ${body.id}`);
|
||||
return;
|
||||
}
|
||||
const result = body.action === "update"
|
||||
? customItems.update(kind, body.id, body)
|
||||
: body.action === "create" ? customItems.create(kind, body, mod.username) : {error: "Unknown action."};
|
||||
: body.action === "create" ? customItems.create(kind, body, actor.username) : {error: "Unknown action."};
|
||||
if (result.error) {
|
||||
done(result);
|
||||
return;
|
||||
@@ -635,8 +724,58 @@ const itemRoutes = (route, url, body, reply, done, mod) => {
|
||||
}
|
||||
};
|
||||
|
||||
// GET review: what waits, the oldest first; POST review {kind, id, approve: true | false}.
|
||||
// for the moderator panel and the admin panel (lib/panel.js) alike.
|
||||
// POST review {action: "takePicture", kind, id}: a picture off an item,
|
||||
// counted against its maker; {action: "uploads", username, blocked}:
|
||||
// stops, or lets again, one player's picture uploads.
|
||||
// `artBase`: the panel's /…/api/itemart, where pictures that wait are shown.
|
||||
const reviewRoutes = (route, body, reply, done, by, artBase) => {
|
||||
if (route === "GET review") {
|
||||
reply(200, {
|
||||
waiting: customItems.waiting().map(entry => {
|
||||
const maker = entry.ownerId === null ? null : accounts.byId(entry.ownerId);
|
||||
return {kind: entry.kind, id: entry.id, name: entry.name, baseName: customItems.baseName(entry), base: entry.base, maker: maker ? maker.username : entry.createdBy,
|
||||
createdAt: entry.createdAt, waiting: entry.pending ? "item" : "picture", artUrl: itemArt.urlOf(entry, artBase),
|
||||
makerStrikes: maker ? maker.artRefusals || 0 : 0};
|
||||
}),
|
||||
enabled: playerItems.enabled(),
|
||||
approval: playerItems.approvalOn(),
|
||||
artApproval: playerItems.artApprovalOn(),
|
||||
strikes: playerItems.ART_STRIKES,
|
||||
stopped: accounts.all().filter(account => account.artBlocked).map(account => account.username).sort(),
|
||||
});
|
||||
return;
|
||||
}
|
||||
if (route === "POST review" && body.action === "takePicture") {
|
||||
const kind = String(body.kind || "");
|
||||
const entry = customItems.get(kind, body.id);
|
||||
const maker = entry && entry.ownerId !== null ? accounts.byId(entry.ownerId) : null;
|
||||
const result = playerItems.takePicture(kind, body.id);
|
||||
done(result, result.ok ? "item picture taken off" : "", maker ? maker.username : "", `${kind} ${body.id}`);
|
||||
return;
|
||||
}
|
||||
if (route === "POST review" && body.action === "uploads") {
|
||||
const target = accounts.byName(String(body.username || "").trim());
|
||||
if (!target) {
|
||||
done({error: "No such player."});
|
||||
return;
|
||||
}
|
||||
const result = playerItems.setUploadsBlocked(target, body.blocked === true);
|
||||
done(result, body.blocked === true ? "picture uploads stopped" : "picture uploads allowed", target.username);
|
||||
return;
|
||||
}
|
||||
if (route === "POST review") {
|
||||
const kind = String(body.kind || "");
|
||||
const result = playerItems.review(kind, body.id, body.approve === true, by, world);
|
||||
done(result, result.ok ? (body.approve === true ? "item approved" : "item turned away") : "", "", `${kind} ${body.id}`);
|
||||
return;
|
||||
}
|
||||
reply(404, {error: "not_found"});
|
||||
};
|
||||
|
||||
const moderators = () => accounts.all().filter(account => roles.roleOf(account))
|
||||
.map(account => ({username: account.username, role: roles.roleOf(account), twoStep: totp.isOn(account), lastSeen: account.lastSeen || null}))
|
||||
.sort((a, b) => a.username.localeCompare(b.username));
|
||||
|
||||
module.exports = {handle, forget, moderators};
|
||||
module.exports = {handle, forget, moderators, signedInAs, itemRoutes, reviewRoutes};
|
||||
Reference in new issue
Block a user