mirror of
https://github.com/burrow-dev/burrow-server.git
synced 2026-11-19 01:27:51 -05:00
Merge origin/main into moderator-tools
Hardware bans, panel search and logs, two worlds and the verified badge, with the branch's staff roles kept: full rooms let in active staff, and address search stays with the roles that may ban addresses. Co-Authored-By: Claude Opus 5.5 <[email protected]>
This commit is contained in:
commit
da7eb9af58
33 files changed
+2771
-166
No files matched your search
+53
-12
@@ -10,6 +10,7 @@ const chatlog = require("./chatlog.js");
|
||||
const config = require("../config.js");
|
||||
const customItems = require("./customitems.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");
|
||||
@@ -48,7 +49,6 @@ const SESSION_HOURS = 12;
|
||||
const TEN_MINUTES_MS = 600000;
|
||||
const MAX_BAN_HOURS = 24 * 365 * 10;
|
||||
const MAX_MESSAGE_LENGTH = 200;
|
||||
const MAX_FOUND = 50;
|
||||
|
||||
const failuresByAddress = limits.limiter(config.failedLoginsPerTenMinutes, TEN_MINUTES_MS);
|
||||
const actionsPerTenMinutes = limits.limiter(300, TEN_MINUTES_MS); // per moderator
|
||||
@@ -104,19 +104,17 @@ const playerRow = (account, playing) => {
|
||||
playtime: account.playtime,
|
||||
bio: account.bio,
|
||||
discord: account.discord,
|
||||
deviceBanned: devices.bannedId(account) !== 0,
|
||||
};
|
||||
};
|
||||
|
||||
const playing = () => new Map(world.players().map(player => [player.username, player.room || "(between rooms)"]));
|
||||
|
||||
// by name (lib/staff.js says in what order).
|
||||
const findPlayers = query => {
|
||||
const wanted = String(query || "").trim().toLowerCase().slice(0, 100);
|
||||
const online = playing();
|
||||
return accounts.all()
|
||||
.filter(account => account.username.toLowerCase().includes(wanted))
|
||||
.sort((a, b) => Number(online.has(b.username)) - Number(online.has(a.username)) || a.username.localeCompare(b.username))
|
||||
.slice(0, MAX_FOUND)
|
||||
.map(account => playerRow(account, online));
|
||||
const {found, total} = staff.findAccounts(query);
|
||||
return {players: found.map(account => playerRow(account, online)), total};
|
||||
};
|
||||
|
||||
// one player: the row, what was done about their bans (without addresses),
|
||||
@@ -127,6 +125,9 @@ const playerDetail = account => ({
|
||||
appeal: bans.appealOf(account),
|
||||
warningList: (account.warnings || []).slice(-20).reverse(),
|
||||
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,
|
||||
});
|
||||
|
||||
// an address with its end left out, and a name to lift its ban by.
|
||||
@@ -264,6 +265,11 @@ const act = (mod, target, body) => {
|
||||
const result = world.staffMove(mod.username, target.username);
|
||||
return result.ok ? {ok: `You went to ${name} (${result.room}).`, detail: result.room} : {error: result.error};
|
||||
}
|
||||
// every computer they signed in from lately (lib/devices.js).
|
||||
case "banDevices":
|
||||
return staff.banDevices(target, body.reason, by);
|
||||
case "unbanDevices":
|
||||
return staff.unbanDevicesOf(target, by);
|
||||
default:
|
||||
return {error: "Unknown action."};
|
||||
}
|
||||
@@ -414,9 +420,36 @@ const handle = async (req, res, url, from, web) => {
|
||||
paintings: masterpieces.list(masterpieces.PENDING).length});
|
||||
return;
|
||||
|
||||
// other accounts the same person may have, and their story (lib/staff.js).
|
||||
case "GET /mod/api/alts": {
|
||||
const account = accounts.byName(url.searchParams.get("username") || "");
|
||||
reply(account ? 200 : 404, account ? {alts: staff.altsOf(account), ids: devices.idsFor(account)} : {error: "No such player."});
|
||||
return;
|
||||
}
|
||||
case "GET /mod/api/timeline": {
|
||||
const account = accounts.byName(url.searchParams.get("username") || "");
|
||||
reply(account ? 200 : 404, account ? {events: staff.timelineOf(account)} : {error: "No such player."});
|
||||
return;
|
||||
}
|
||||
// who the server's chat filter stopped most this week.
|
||||
case "GET /mod/api/filterhits":
|
||||
reply(200, {players: chatlog.mostStopped(7, 50)});
|
||||
return;
|
||||
|
||||
case "GET /mod/api/players": {
|
||||
if (url.searchParams.get("by") !== "address") {
|
||||
reply(200, {players: findPlayers(url.searchParams.get("q"))});
|
||||
const searchBy = url.searchParams.get("by");
|
||||
if (searchBy === "device") {
|
||||
const found = staff.byDevice(url.searchParams.get("q"));
|
||||
if (found.error) {
|
||||
reply(400, found);
|
||||
return;
|
||||
}
|
||||
const online = playing();
|
||||
reply(200, {players: found.players.map(entry => ({...playerRow(accounts.byName(entry.username), online), matchedAt: entry.lastAt}))});
|
||||
return;
|
||||
}
|
||||
if (searchBy !== "address") {
|
||||
reply(200, findPlayers(url.searchParams.get("q")));
|
||||
return;
|
||||
}
|
||||
// by address: only the address typed, which is written down (once
|
||||
@@ -466,7 +499,8 @@ const handle = async (req, res, url, from, web) => {
|
||||
case "GET /mod/api/chat": {
|
||||
const params = url.searchParams;
|
||||
const lines = chatlog.search({username: (params.get("username") || "").trim().slice(0, 100), room: (params.get("room") || "").trim().slice(0, 100),
|
||||
text: (params.get("text") || "").trim().slice(0, 100), before: Number(params.get("before")) || 0});
|
||||
text: (params.get("text") || "").trim().slice(0, 100), kind: params.get("kind") || "", direction: params.get("direction") || "", until: Number(params.get("until")) || 0,
|
||||
before: Number(params.get("before")) || 0});
|
||||
reply(200, {lines, more: lines.length === chatlog.PAGE, days: config.chatLogDays});
|
||||
return;
|
||||
}
|
||||
@@ -506,7 +540,7 @@ const handle = async (req, res, url, from, web) => {
|
||||
}
|
||||
|
||||
case "GET /mod/api/bans":
|
||||
reply(200, {accounts: staff.disciplined(), addresses: bans.addressBans().map(maskedAddress)});
|
||||
reply(200, {accounts: staff.disciplined(), addresses: bans.addressBans().map(maskedAddress), devices: devices.list(), alerts: devices.alerts()});
|
||||
return;
|
||||
|
||||
case "POST /mod/api/address": {
|
||||
@@ -519,9 +553,16 @@ const handle = async (req, res, url, from, web) => {
|
||||
return;
|
||||
}
|
||||
|
||||
// A device ban lifted (lib/devices.js).
|
||||
case "POST /mod/api/device": {
|
||||
const result = staff.unbanDevices(body.id, mod.username);
|
||||
done(result, "hardware ban lifted", result.username || "");
|
||||
return;
|
||||
}
|
||||
|
||||
// paintings players framed (lib/masterpieces.js).
|
||||
case "GET /mod/api/masterpieces":
|
||||
reply(200, {waiting: masterpieces.list(masterpieces.PENDING), approved: masterpieces.list(masterpieces.APPROVED)});
|
||||
reply(200, {...masterpieces.listsFor(url.searchParams.get("creator")), waitingCount: masterpieces.list(masterpieces.PENDING).length});
|
||||
return;
|
||||
|
||||
case "GET /mod/api/masterpiece": {
|
||||
|
||||
Reference in new issue
Block a user