feat: stats graphs, playtime, ip search against ban evasion, 150-char chat

- stats graphs for the admin and moderator panels (lib/stats.js, public/stats-view.html)
- playtime, private unless shown on the card's bio tab; set on the account page
- search accounts by ip address, only against ban evasion; mods see no addresses and each search is logged
- privacy policy for the above (terms version 2026-10-17)
- the per-second save looks only at accounts in play, with a slow sweep of the rest
- items in several dens at once; chat filter hides slurs and threats by default
- sexual usernames refused; moderators may enter full rooms; guide login allowed
- 150-character chat box (client build 55)
- fixes: gifts, trades, dens, pets in dens, den recycling, special animals' colours,
  jammer walls, settings switches; the buddy list sent at login
- the item giver, the rules screen and the art studio rework
This commit is contained in:
Burrowdev committed 2026-10-17 02:00:57 +03:00
1 parent 8400d2f928
commit 04f468af2c
56 files changed
+25667 -3894

No files matched your search

+35 -7
View File
@@ -14,6 +14,7 @@ const masterpieces = require("./masterpieces.js");
const modlog = require("./modlog.js");
const reports = require("./reports.js");
const staff = require("./staff.js");
const stats = require("./stats.js");
const support = require("./support.js");
const totp = require("./totp.js");
const world = require("./world.js");
@@ -28,10 +29,13 @@ const world = require("./world.js");
// cannot sign in at all, and a trusted device is not taken for a code.
// being a moderator gives the account nothing in the game itself.
//
// what it does not give: addresses, sign-in histories, the server's log,
// what an account owns, passwords, renaming, deleting, gifts. an address
// can be banned through its player (the one they last signed in from) and
// shows here with its end left out. another moderator cannot be acted on.
// what it does not give: sign-in histories, the server's log, what an
// account owns, passwords, renaming, deleting, gifts. a moderator may look
// up which players signed in from an address they already have (a search
// written down under their name, below), but is shown no others; an
// address can be banned through its player (the one they last signed in
// from) and shows here with its end left out. another moderator cannot be
// acted on.
// everything done here is written down (lib/modlog.js) under the
// moderator's name, for the admin panel.
@@ -46,6 +50,7 @@ const failuresByAddress = limits.limiter(config.failedLoginsPerTenMinutes, TEN_M
const actionsPerTenMinutes = limits.limiter(300, TEN_MINUTES_MS); // per moderator
const sessions = new Map(); // SHA-256 of a session token -> {id: account id, expiry: ms}
const addressSearched = new Map(); // moderator's account id -> the address they last searched for
const sha256 = text => crypto.createHash("sha256").update(text).digest("hex");
@@ -91,6 +96,7 @@ const playerRow = (account, playing) => {
silenced: world.moderation.silenceRemaining(account),
nameRejected: Boolean(account.nameRejected),
moderator: Boolean(account.moderator),
playtime: account.playtime,
bio: account.bio,
discord: account.discord,
};
@@ -230,7 +236,7 @@ const handle = async (req, res, url, from, web) => {
const route = `${req.method} ${url.pathname.replace(/\/$/, "") || "/mod"}`;
if (route === "GET /mod") {
web.send(res, 200, captcha.withScriptVersion(await fs.promises.readFile(path.join(config.publicDir, "mod.html"))), "text/html; charset=utf-8");
web.send(res, 200, captcha.withScriptVersion(await stats.withView(await fs.promises.readFile(path.join(config.publicDir, "mod.html")))), "text/html; charset=utf-8");
return;
}
if (req.method === "POST" && !limits.originAllowed(req)) {
@@ -333,8 +339,30 @@ const handle = async (req, res, url, from, web) => {
paintings: masterpieces.list(masterpieces.PENDING).length});
return;
case "GET /mod/api/players":
reply(200, {players: findPlayers(url.searchParams.get("q"))});
case "GET /mod/api/players": {
if (url.searchParams.get("by") !== "address") {
reply(200, {players: findPlayers(url.searchParams.get("q"))});
return;
}
// by address: only the address typed, which is written down (once
// for each address, though the page asks again every few seconds).
const query = String(url.searchParams.get("q") || "").trim().toLowerCase();
const found = staff.byAddress(query);
if (found.error) {
reply(400, found);
return;
}
if (addressSearched.get(mod.id) !== query) {
addressSearched.set(mod.id, query);
modlog.record(mod.username, "searched by address", "", `${query} · ${found.players.length} found`);
}
const online = playing();
reply(200, {players: found.players.map(entry => ({...playerRow(accounts.byName(entry.username), online), matchedAt: entry.lastAt}))});
return;
}
case "GET /mod/api/stats":
reply(200, stats.report(Number(url.searchParams.get("days")), Number(url.searchParams.get("offset"))));
return;
case "GET /mod/api/player": {