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:
SnipzilandClaude Opus 5.5 committed 2026-10-17 21:44:10 -04:00
1 parent da7eb9af58
commit e05565787f
50 files changed
+2904 -277

No files matched your search

+16 -17
View File
@@ -46,7 +46,7 @@ const wall = async body => (await postJson(`${BASE}/wall`, body)).json();
const run = async () => {
const registerJson = body => fetch(`${BASE}/api/register`, {method: "POST", headers: {"Content-Type": "application/json"}, body: JSON.stringify({avatarType: 1, agreed: true, ...body})});
for (const username of ["Ann", "Ben", "Cat", "Scout"]) {
assert.strictEqual((await registerJson({username, password: "Password01"})).status, 200);
assert.strictEqual((await registerJson({username, password: "KettlePass01"})).status, 200);
}
// --- the admin panel's message of the day reaches a player once their first room has loaded
@@ -62,7 +62,7 @@ const run = async () => {
assert.strictEqual((await panel("motd", {text: "Welcome to the test server"}, admin)).status, 200);
assert.strictEqual((await panel("messages", undefined, admin)).data.motd, "Welcome to the test server");
const {client: a, login: annLogin, roomId} = await arrive("Ann", "Password01");
const {client: a, login: annLogin, roomId} = await arrive("Ann", "KettlePass01");
// "ua": the text sits where a room id usually does, then 1 = system message.
assert.deepStrictEqual((await a.untilXt("ua")).slice(1), ["Welcome to the test server", "1"]);
assert.strictEqual((await panel("motd", {text: ""}, admin)).status, 200);
@@ -81,7 +81,7 @@ const run = async () => {
a.xt("pad", roomId, "Ann");
assert.deepStrictEqual((await a.nextXt("pad")).slice(2), ["1", "1", String(annLogin.params.usableAdoptAPetDefs[0].defId), String(annLogin.params.usableAdoptAPetDefs[0].invId)]);
const {client: b, login: benLogin} = await arrive("Ben", "Password01");
const {client: b, login: benLogin} = await arrive("Ben", "KettlePass01");
await a.untilXt("ac");
await a.nextXt("il");
@@ -90,7 +90,7 @@ const run = async () => {
// path. a scout goes in first and comes back until the file has been read,
// so that what follows does not depend on what an earlier run left in the
// cache. (the scout never enters the township, so a and b see nothing.)
const scoutAuth = await (await postJson(`${BASE}/authenticate`, {username: "Scout", password: "Password01"})).json();
const scoutAuth = await (await postJson(`${BASE}/authenticate`, {username: "Scout", password: "KettlePass01"})).json();
const scout = new harness.GameClient(GAME_PORT);
await scout.connect();
assert.strictEqual((await scout.logIn("Scout", scoutAuth.auth_token)).status, "1");
@@ -200,7 +200,7 @@ const run = async () => {
// --- name tags: the colour and badge go with a colour change, reach the room, and stay
a.xt("gl", roomId, 110);
const badges = await a.nextXt("gl");
assert.deepStrictEqual([badges[3], badges[8], badges[9], badges[70]], ["1049", "75", "1", "62"]); // every badge, in id order: the game's 62 and the thirteen the admin gives
assert.deepStrictEqual([badges[3], badges[8], badges[9], badges[70]], ["1049", "76", "1", "62"]); // every badge, in id order: the game's 62 and the fourteen the admin gives (verified among them)
const tag = 6 | 11 << 8; // colour 6, the twelfth badge
a.xt("ap", roomId, 1, 2, 3, tag);
assert.deepStrictEqual((await a.nextXt("ap")).slice(2), ["1"]);
@@ -435,18 +435,9 @@ const run = async () => {
b.xt("ei", own[4], 0);
await b.nextXt("ei");
// A secret valentine: the receiver is not told who sent it, the server knows.
// secret valentines are off (lib/ecards.js): one asked for is refused
a.xt("es", own[4], "Ben", cards[9], stamps[9], 2, "GUESS WHO", 0, 0, 1);
assert.deepStrictEqual((await a.nextXt("es")).slice(2), ["1"]);
const valentine = await b.nextXt("ep");
assert.deepStrictEqual([valentine[3], valentine[7], valentine[18]], ["", "GUESS WHO", "1"]); // no name; special type 1
b.xt("fr", own[4], "Secret Valentine", 14); // reported under the name the game shows
assert.deepStrictEqual((await b.nextXt("fr")).slice(2), ["1"]);
const aboutValentine = (await panel("reports", undefined, admin)).data.reports;
assert.deepStrictEqual([aboutValentine[0].reporter, aboutValentine[0].target, aboutValentine[0].reason], ["Ben", "Ann", "Inappropriate Jam-A-Gram"]);
await panel("report", {id: aboutValentine[0].id}, admin);
b.xt("ed", own[4], valentine[2]);
await b.nextXt("ed");
assert.deepStrictEqual((await a.nextXt("es")).slice(2), ["0"]);
// --- Jammer Walls: the wallpapers a wall cannot be drawn without, and their buttons
a.xt("gl", own[4], 314);
@@ -488,6 +479,14 @@ const run = async () => {
assert.deepStrictEqual((await b.nextXt("wps")).slice(2), ["1"]);
const mine = await wall({cmd: "GET", t: ownToken});
assert.deepStrictEqual([mine.p.bg, mine.p.tag, mine.p.visits, mine.r.length], ["7", "hello there", 1, 1]); // visits are not the owner's to set
// the photo booth picture: its animal, its pet and what it wears, kept
const photo = {avatar: {id: 4, color1: 1463028479, color2: 603979776, color3: 83885823, eyes: 4, pattern: 25}, bgid: 3,
pet: {ts: 1792133948, lbits: 25, uBits: 0, eBits: 0}, items: [{id: 101, color: 1463028479}, {id: 202, color: 0}]};
b.xt("wps", own[4], JSON.stringify({pb: photo}));
assert.deepStrictEqual((await b.nextXt("wps")).slice(2), ["1"]);
assert.deepStrictEqual((await wall({cmd: "GET", t: ownToken})).p.pb, photo);
b.xt("wps", own[4], JSON.stringify({pb: {avatar: {deep: {deeper: 1}}}})); // but no deeper than that
assert.deepStrictEqual((await b.nextXt("wps")).slice(2), ["0"]);
assert.deepStrictEqual(await wall({cmd: "CLW", t: token[3]}), {s: false}); // only the owner clears a wall
assert.deepStrictEqual(await wall({cmd: "DEL", t: ownToken, x: put.x}), {s: true});
assert.strictEqual((await wall({cmd: "GET", t: ownToken})).r.length, 0);
@@ -515,7 +514,7 @@ const run = async () => {
assert.strictEqual((await panel("overview", undefined, admin)).data.stats.reports, 1);
assert.strictEqual((await panel("report", {id: waiting.reports[0].id}, admin)).status, 200);
assert.strictEqual((await panel("reports", undefined, admin)).data.open, 0);
assert.strictEqual((await panel("reports?handled=1", undefined, admin)).data.reports.length, 2); // this one and the valentine
assert.strictEqual((await panel("reports?handled=1", undefined, admin)).data.reports.length, 1); // this one (secret valentines, reported before, are off)
// --- blocking: no chat from them, out of my party and my den, and out of sight if I say so
a.xt("bb", own[4], "Ben");