mirror of
https://github.com/burrow-dev/burrow-server.git
synced 2026-11-21 09:37:50 -05:00
Compare commits
6
Commits
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
4997315239 | ||
|
|
1e365b95c5 | ||
|
|
a359371a48 | ||
|
|
33f56074a4 | ||
|
|
1d9b70f32e | ||
|
|
3770341514 |
No files matched your search
@@ -3,6 +3,7 @@
|
||||
"ajcontent.akamaized.net",
|
||||
"burrow.moe",
|
||||
"cdn.jsdelivr.net",
|
||||
"discord.com",
|
||||
"challenges.cloudflare.com",
|
||||
"play.burrow.moe",
|
||||
"vision.googleapis.com",
|
||||
|
||||
@@ -108,12 +108,23 @@ module.exports = {
|
||||
// emoji pictures for chat (lib/emoji.js): Twemoji's, at one version
|
||||
emojiUpstream: env.AJ_EMOJI_UPSTREAM || "https://cdn.jsdelivr.net/gh/jdecked/[email protected]/assets/72x72/",
|
||||
offline: env.AJ_OFFLINE === "1",
|
||||
// the client's device ids (lib/devices.js): with AJ_REQUIRE_DEVICE=1, a
|
||||
// sign-in without them (a client from before 1.3.0, the official
|
||||
// launcher, or one that left them out) is refused. off for now, while
|
||||
// players update to 1.3.0: they are let in, and an account seen on banned
|
||||
// hardware before is still kept out.
|
||||
requireDevice: env.AJ_REQUIRE_DEVICE === "1",
|
||||
// the client's device ids (lib/devices.js): a game whose launcher sent none
|
||||
// (a client from before 1.3.0, the official launcher, or one that left
|
||||
// them out) is turned away at its login, its popup saying to update.
|
||||
// AJ_REQUIRE_DEVICE=0 lets them in (an account seen on banned hardware
|
||||
// before is still kept out).
|
||||
requireDevice: env.AJ_REQUIRE_DEVICE !== "0",
|
||||
// Discord (lib/discord.js): an application's id and secret for linking a
|
||||
// player's Discord account on the account page (its OAuth2 redirect must
|
||||
// be <siteUrl>account/discord/callback), and a bot in Burrow's Discord
|
||||
// server for the booster badge. linking is off without the first two, the
|
||||
// booster badge left alone without the last two.
|
||||
discord: {
|
||||
clientId: env.AJ_DISCORD_CLIENT_ID || "",
|
||||
clientSecret: env.AJ_DISCORD_CLIENT_SECRET || "",
|
||||
botToken: env.AJ_DISCORD_BOT_TOKEN || "",
|
||||
guildId: env.AJ_DISCORD_GUILD_ID || "",
|
||||
},
|
||||
deployVersion: env.AJ_DEPLOY_VERSION || "1830",
|
||||
// older builds the CDN still serves, asked in turn for a room file the
|
||||
// current build has dropped. 1828 is the last with the Summer Carnival.
|
||||
@@ -134,7 +145,7 @@ module.exports = {
|
||||
// 49 and 50: its link to a colour picker.
|
||||
// 61: the Owner, Moderator and Verified name tag badges seen by everyone.
|
||||
// 62: "Custom pictures" in the settings menu, to hide players' item pictures.
|
||||
buildVersion: env.AJ_BUILD_VERSION || "62",
|
||||
buildVersion: env.AJ_BUILD_VERSION || "71",
|
||||
// what the official CDN is asked for; not ours to change.
|
||||
upstreamBuildVersion: "3",
|
||||
|
||||
|
||||
+6
-2
@@ -27,8 +27,12 @@ for file in $(git diff --name-only "$old" "$new" -- '*.js'); do
|
||||
fi
|
||||
done
|
||||
|
||||
# public/ is read from disk on every request; the rest is loaded once, at start
|
||||
if git diff --name-only "$old" "$new" | grep -qvE '^(public/|client-updates/|test/|tools/|deploy/|[^/]+\.md$|\.gitignore$)'; then
|
||||
# public/ is read from disk on every request; the rest is loaded once, at start.
|
||||
# the list is taken whole first: piped straight into grep -q, a long one (a
|
||||
# push of many files) had git cut off mid-write ("Broken pipe"), which
|
||||
# pipefail read as nothing to restart for.
|
||||
changed=$(git diff --name-only "$old" "$new")
|
||||
if grep -qvE '^(public/|client-updates/|test/|tools/|deploy/|[^/]+\.md$|\.gitignore$)' <<<"$changed"; then
|
||||
systemctl restart "$service"
|
||||
echo "updated $old -> $new, restarted $service"
|
||||
else
|
||||
|
||||
+12
-2
@@ -245,7 +245,10 @@ const normalize = account => {
|
||||
account.nameBarData = Number.isInteger(account.nameBarData) ? account.nameBarData : 0;
|
||||
account.disguise = Number.isInteger(account.disguise) ? account.disguise : 0; // NPC id, see lib/disguises.js
|
||||
// shown on the player's card: lib/badges.js.
|
||||
account.discord = typeof account.discord === "string" ? account.discord : ""; // their Discord username, as they gave it
|
||||
account.discord = typeof account.discord === "string" ? account.discord : ""; // their Discord username, as Discord gave it (lib/discord.js)
|
||||
if (account.discordId !== undefined && !/^\d{5,25}$/.test(String(account.discordId))) {
|
||||
delete account.discordId; // the linked Discord account's id
|
||||
}
|
||||
account.badges = Array.isArray(account.badges) ? account.badges : []; // badge ids, given in the admin panel
|
||||
account.bio = typeof account.bio === "string" ? account.bio : ""; // their own words, for the card's Bio tab
|
||||
// seconds spent in the game in all (lib/world.js counts it), and whether
|
||||
@@ -905,10 +908,17 @@ const byToken = token => {
|
||||
|
||||
const byName = username => touch(byKey.get(String(username).toLowerCase())) || null;
|
||||
|
||||
// a username as its account spells it, or null. only asks whether there is
|
||||
// one: unlike byName it does not count as the account being in use.
|
||||
const nameOf = username => {
|
||||
const account = byKey.get(String(username).toLowerCase());
|
||||
return account ? account.username : null;
|
||||
};
|
||||
|
||||
const accountById = id => touch(byId.get(Number(id))) || null;
|
||||
|
||||
const all = () => [...byId.values()];
|
||||
|
||||
const database = () => db;
|
||||
|
||||
module.exports = {FEATURES, featureOn, recordLogin, revokeTokens, load, save, flush, hold, release, startBackups, database, setLoginChoices, setPassword, rename, remove, setting, setSetting, hashPassword, register, usernameProblem, authenticate, authenticateAsync, issueToken, byToken, byName, byId: accountById, newAvatar, freeAvatarSlot, all};
|
||||
module.exports = {FEATURES, featureOn, recordLogin, revokeTokens, load, save, flush, hold, release, startBackups, database, setLoginChoices, setPassword, rename, remove, setting, setSetting, hashPassword, register, usernameProblem, authenticate, authenticateAsync, issueToken, byToken, byName, nameOf, byId: accountById, newAvatar, freeAvatarSlot, all};
|
||||
@@ -110,6 +110,12 @@ const give = (body, seesLocked = false) => {
|
||||
}
|
||||
custom = String(entry.id);
|
||||
}
|
||||
// a colour id written signed, as lists of the game's colours often do
|
||||
// them: the same 32 bits, kept as the game keeps colours (unsigned), so
|
||||
// -16777216 is 4278190080.
|
||||
if (/^-\d{1,10}$/.test(custom) && Number(custom) >= -0x80000000) {
|
||||
custom = String(Number(custom) >>> 0);
|
||||
}
|
||||
if (custom && !isUint(custom)) {
|
||||
return {status: 400, body: {error: "Colour: an id, or #RRGGBB"}};
|
||||
}
|
||||
|
||||
+5
-3
@@ -104,12 +104,12 @@ module.exports = ({others, findOnline, findBySfsId, refreshForOthers, petFields}
|
||||
}
|
||||
},
|
||||
|
||||
// AvatarSwitch.avatarKillResponse: [success, ?]
|
||||
// AvatarSwitch.avatarKillResponse: [success, gems]
|
||||
ak(session, roomId, [perUserAvId]) {
|
||||
const {account} = session;
|
||||
const avatar = account.avatars.find(candidate => candidate.perUserAvId === Number(perUserAvId));
|
||||
if (!avatar || avatar === activeAvatar(account) || account.avatars.length < 2) {
|
||||
session.sendXt("ak", -1, 0, 0);
|
||||
session.sendXt("ak", -1, 0, account.currency.gems);
|
||||
return;
|
||||
}
|
||||
account.avatars = account.avatars.filter(candidate => candidate !== avatar);
|
||||
@@ -117,7 +117,9 @@ module.exports = ({others, findOnline, findBySfsId, refreshForOthers, petFields}
|
||||
item.on = item.on.filter(avInvId => avInvId !== avatar.avInvId);
|
||||
}
|
||||
accounts.save(account);
|
||||
session.sendXt("ak", -1, 1, 0);
|
||||
// [success, gems]: the animal switcher (AvatarSwitcher.recycleAvatarCallback)
|
||||
// shows the second as the player's gems, so it is their total, unchanged.
|
||||
session.sendXt("ak", -1, 1, account.currency.gems);
|
||||
},
|
||||
|
||||
// AvatarXtCommManager.requestColorChange: [color1, color2, color3, nameBarData]
|
||||
|
||||
+1
-1
@@ -65,7 +65,7 @@ const set = (account, ids) => {
|
||||
};
|
||||
|
||||
// A Discord username as Discord has them now: 2 to 32 of a-z, 0-9, "_" and
|
||||
// ".", with no two dots in a row. nobody checks that it is theirs.
|
||||
// ".", with no two dots in a row. players link theirs (lib/discord.js).
|
||||
const DISCORD_NAME = /^(?!.*\.\.)[a-z0-9_.]{2,32}$/;
|
||||
|
||||
// returns the username as it will be kept ("" for none), or null when it
|
||||
|
||||
@@ -144,6 +144,9 @@ const withRestoredParties = pack => {
|
||||
// text of our own, for things the game has no string for. added to the
|
||||
// English localization pack under ids far above the game's (about 41,000).
|
||||
const ADDED_STRINGS = {
|
||||
// the login popup for a launcher too old to send device ids (lib/world.js
|
||||
// LOGIN_OUTDATED), in place of "Your account is currently under maintenance."
|
||||
11198: "Your client is outdated. Update at https://burrow.moe/download",
|
||||
9000001: "Castle (2010 draft)",
|
||||
9000002: "Water Park (three slides)",
|
||||
9000003: "Water Park (five slides)",
|
||||
|
||||
+29
-1
@@ -308,6 +308,13 @@ const unban = id => {
|
||||
return ban;
|
||||
};
|
||||
|
||||
// one ban as kept, with the account it was made with (accountId), or null:
|
||||
// for the moderator panel to see whose it is before lifting it.
|
||||
const banById = id => {
|
||||
const row = db().prepare("SELECT * FROM device_bans WHERE id = ?").get(Number(id));
|
||||
return row ? banRow(row) : null;
|
||||
};
|
||||
|
||||
// the bans, newest first: their ids, and the accounts that used them.
|
||||
const MAX_LISTED_ACCOUNTS = 20;
|
||||
const list = () => db().prepare("SELECT * FROM device_bans ORDER BY id DESC").all().map(banRow)
|
||||
@@ -397,4 +404,25 @@ const forget = account => {
|
||||
db().prepare("DELETE FROM device_alerts WHERE account_id = ?").run(account.id);
|
||||
};
|
||||
|
||||
module.exports = {load, read, banOf, banOfAccount, seen, alts, knownFor, banAccount, accountsUnder, unban, list, idsFor, bansOfAccount, search, bannedId, alerts, alertsOf, forget, clientHash};
|
||||
// sign-in tokens last given to (or brought back by) a launcher that sent no
|
||||
// device ids: one from before 1.3.0, or not ours. with config.requireDevice
|
||||
// its sign-in still goes through, so that the game loads and its own login
|
||||
// popup can say to update (lib/world.js), which a refused sign-in cannot.
|
||||
// kept by hash, in memory: such a launcher signs in again each time it starts.
|
||||
const MAX_OUTDATED = 20000;
|
||||
const outdatedTokens = new Set();
|
||||
const tokenKey = token => crypto.createHash("sha256").update(String(token)).digest("hex");
|
||||
const noteLauncher = (token, hasIds) => {
|
||||
const key = tokenKey(token);
|
||||
if (hasIds) {
|
||||
outdatedTokens.delete(key);
|
||||
return;
|
||||
}
|
||||
if (outdatedTokens.size >= MAX_OUTDATED) {
|
||||
outdatedTokens.delete(outdatedTokens.values().next().value);
|
||||
}
|
||||
outdatedTokens.add(key);
|
||||
};
|
||||
const launcherOutdated = token => outdatedTokens.has(tokenKey(token));
|
||||
|
||||
module.exports = {noteLauncher, launcherOutdated, load, read, banOf, banOfAccount, seen, alts, knownFor, banAccount, accountsUnder, unban, banById, list, idsFor, bansOfAccount, search, bannedId, alerts, alertsOf, forget, clientHash};
|
||||
+205
@@ -0,0 +1,205 @@
|
||||
"use strict";
|
||||
|
||||
const crypto = require("crypto");
|
||||
const {logText} = require("./logtext.js");
|
||||
const accounts = require("./accounts.js");
|
||||
const badges = require("./badges.js");
|
||||
const config = require("../config.js");
|
||||
|
||||
// a player's Discord account, linked on the account page by signing in to
|
||||
// Discord (OAuth2, scope "identify"): the only way a Discord username gets
|
||||
// onto a player's card, so the name shown is theirs. one Discord account
|
||||
// for one Burrow account, or a single boost would badge a player's every
|
||||
// account.
|
||||
//
|
||||
// the Discord Server Booster badge follows the linked account: given while
|
||||
// it boosts Burrow's Discord server, taken off when it stops, checked when
|
||||
// the account is linked and again every RECHECK_HOURS. Burrow's bot asks
|
||||
// Discord (GET /guilds/<id>/members/<user id>, which needs no privileged
|
||||
// intent: the bot only has to be in the server). an account that is not
|
||||
// linked keeps whatever badges the admin gave it.
|
||||
//
|
||||
// with AJ_DISCORD_CLIENT_ID and AJ_DISCORD_CLIENT_SECRET unset, linking is
|
||||
// off; without AJ_DISCORD_BOT_TOKEN and AJ_DISCORD_GUILD_ID, the booster
|
||||
// badge is left alone.
|
||||
|
||||
const API = "https://discord.com/api/v10";
|
||||
const AUTHORIZE = "https://discord.com/oauth2/authorize";
|
||||
const STATE_MINUTES = 10;
|
||||
const MAX_STATES = 10000;
|
||||
const RECHECK_HOURS = 6;
|
||||
const RECHECK_GAP_MS = 300; // between two members asked about, under Discord's rate limit
|
||||
const TIMEOUT_MS = 15000;
|
||||
const BOOSTER = "booster";
|
||||
|
||||
const linking = () => Boolean(config.discord.clientId && config.discord.clientSecret);
|
||||
const boostChecks = () => Boolean(config.discord.botToken && config.discord.guildId);
|
||||
const redirectUri = () => `${config.siteUrl}account/discord/callback`;
|
||||
|
||||
// a link under way: state (in Discord's address) -> {accountId, nonce (in a
|
||||
// cookie of the browser that asked), expires}. both must come back.
|
||||
const states = new Map();
|
||||
|
||||
const start = account => {
|
||||
for (const [state, entry] of states) {
|
||||
if (entry.expires < Date.now()) {
|
||||
states.delete(state);
|
||||
}
|
||||
}
|
||||
if (states.size >= MAX_STATES) {
|
||||
states.delete(states.keys().next().value);
|
||||
}
|
||||
const state = crypto.randomBytes(24).toString("hex");
|
||||
const nonce = crypto.randomBytes(24).toString("hex");
|
||||
states.set(state, {accountId: account.id, nonce, expires: Date.now() + STATE_MINUTES * 60000});
|
||||
const url = new URL(AUTHORIZE);
|
||||
url.search = new URLSearchParams({client_id: config.discord.clientId, response_type: "code", scope: "identify",
|
||||
redirect_uri: redirectUri(), state, prompt: "consent"}).toString();
|
||||
return {url: url.href, nonce};
|
||||
};
|
||||
|
||||
const call = async (path, options = {}) => {
|
||||
const res = await fetch(`${API}${path}`, {...options, signal: AbortSignal.timeout(TIMEOUT_MS)});
|
||||
const body = await res.json().catch(() => ({}));
|
||||
return {status: res.status, body};
|
||||
};
|
||||
|
||||
// how a Discord username is kept and shown: as Discord spells them now, or,
|
||||
// for an old "name#1234" one, without the characters a card cannot carry.
|
||||
const shownName = user => badges.discordName(user.username)
|
||||
|| `${String(user.username).replace(/[,|%\s]/g, "")}${user.discriminator && user.discriminator !== "0" ? `#${user.discriminator}` : ""}`.slice(0, 40);
|
||||
|
||||
const setBooster = (account, on) => {
|
||||
if (account.badges.includes(BOOSTER) === on) {
|
||||
return false;
|
||||
}
|
||||
badges.set(account, on ? [...account.badges, BOOSTER] : account.badges.filter(id => id !== BOOSTER));
|
||||
return true;
|
||||
};
|
||||
|
||||
// whether the linked account boosts the server now: true, false, or null
|
||||
// when Discord could not be asked.
|
||||
const boosting = async account => {
|
||||
if (!boostChecks() || !account.discordId) {
|
||||
return null;
|
||||
}
|
||||
for (let attempt = 0; attempt < 3; attempt++) {
|
||||
const {status, body} = await call(`/guilds/${config.discord.guildId}/members/${account.discordId}`,
|
||||
{headers: {Authorization: `Bot ${config.discord.botToken}`}}).catch(() => ({status: 0, body: {}}));
|
||||
if (status === 200) {
|
||||
return Boolean(body.premium_since);
|
||||
}
|
||||
if (status === 404) {
|
||||
return false; // not in the server (any more)
|
||||
}
|
||||
if (status === 429) {
|
||||
await new Promise(resolve => setTimeout(resolve, Math.min(60, Number(body.retry_after) || 5) * 1000));
|
||||
continue;
|
||||
}
|
||||
console.log(`[discord] could not check ${logText(account.username)}'s boost: ${logText(status)}`);
|
||||
return null;
|
||||
}
|
||||
return null;
|
||||
};
|
||||
|
||||
const checkBoost = async account => {
|
||||
const on = await boosting(account);
|
||||
if (on !== null && setBooster(account, on)) {
|
||||
accounts.save(account);
|
||||
console.log(`[discord] ${logText(account.username)} ${on ? "boosts: booster badge given" : "no longer boosts: booster badge taken off"}`);
|
||||
}
|
||||
};
|
||||
|
||||
// the end of a link: the code Discord gave, for the state and the nonce the
|
||||
// browser brought back. {ok, account} or {error}.
|
||||
const finish = async (state, nonce, code) => {
|
||||
const entry = typeof state === "string" ? states.get(state) : null;
|
||||
states.delete(state);
|
||||
const digest = text => crypto.createHash("sha256").update(String(text)).digest();
|
||||
if (!entry || entry.expires < Date.now() || typeof nonce !== "string" || !crypto.timingSafeEqual(digest(entry.nonce), digest(nonce))) {
|
||||
return {error: "expired"};
|
||||
}
|
||||
const account = accounts.byId(entry.accountId);
|
||||
if (!account || typeof code !== "string" || !code) {
|
||||
return {error: "expired"};
|
||||
}
|
||||
try {
|
||||
const token = await call("/oauth2/token", {
|
||||
method: "POST",
|
||||
headers: {"Content-Type": "application/x-www-form-urlencoded"},
|
||||
body: new URLSearchParams({client_id: config.discord.clientId, client_secret: config.discord.clientSecret,
|
||||
grant_type: "authorization_code", code, redirect_uri: redirectUri()}).toString(),
|
||||
});
|
||||
if (token.status !== 200 || !token.body.access_token) {
|
||||
return {error: "discord"};
|
||||
}
|
||||
const me = await call("/users/@me", {headers: {Authorization: `Bearer ${token.body.access_token}`}});
|
||||
if (me.status !== 200 || !/^\d{5,25}$/.test(String(me.body.id))) {
|
||||
return {error: "discord"};
|
||||
}
|
||||
const id = String(me.body.id);
|
||||
if (accounts.all().some(other => other !== account && other.discordId === id)) {
|
||||
return {error: "taken"};
|
||||
}
|
||||
account.discordId = id;
|
||||
account.discord = shownName(me.body);
|
||||
accounts.save(account);
|
||||
console.log(`[discord] ${logText(account.username)} linked Discord ${logText(account.discord)} (${logText(id)})`);
|
||||
await checkBoost(account);
|
||||
return {ok: true, account};
|
||||
}
|
||||
catch (err) {
|
||||
console.log(`[discord] link failed: ${logText(err.message)}`);
|
||||
return {error: "discord"};
|
||||
}
|
||||
};
|
||||
|
||||
// the link undone, by the player or an admin; the booster badge goes with it.
|
||||
const unlink = account => {
|
||||
const had = Boolean(account.discordId || account.discord);
|
||||
delete account.discordId;
|
||||
account.discord = "";
|
||||
if (had) {
|
||||
setBooster(account, false);
|
||||
}
|
||||
accounts.save(account);
|
||||
return had;
|
||||
};
|
||||
|
||||
// every linked account in turn, a little apart, again and again.
|
||||
let rechecking = false;
|
||||
const recheckAll = async () => {
|
||||
if (rechecking || !boostChecks()) {
|
||||
return;
|
||||
}
|
||||
rechecking = true;
|
||||
try {
|
||||
for (const account of accounts.all().filter(one => one.discordId)) {
|
||||
await checkBoost(account);
|
||||
await new Promise(resolve => setTimeout(resolve, RECHECK_GAP_MS));
|
||||
}
|
||||
}
|
||||
finally {
|
||||
rechecking = false;
|
||||
}
|
||||
};
|
||||
|
||||
// at start: Discord usernames typed in by hand before linking existed are
|
||||
// cleared (only a linked one is shown now), then the boosts are looked at
|
||||
// and looked at again every RECHECK_HOURS.
|
||||
const startup = () => {
|
||||
const typed = accounts.all().filter(account => account.discord && !account.discordId);
|
||||
for (const account of typed) {
|
||||
account.discord = "";
|
||||
}
|
||||
if (typed.length) {
|
||||
accounts.save(...typed);
|
||||
console.log(`[discord] ${typed.length} Discord usernames typed in by hand were cleared`);
|
||||
}
|
||||
if (boostChecks()) {
|
||||
setTimeout(recheckAll, 30000).unref();
|
||||
setInterval(recheckAll, RECHECK_HOURS * 3600000).unref();
|
||||
}
|
||||
};
|
||||
|
||||
module.exports = {linking, boostChecks, start, finish, unlink, startup};
|
||||
+53
-2
@@ -1,5 +1,7 @@
|
||||
"use strict";
|
||||
|
||||
const fs = require("fs");
|
||||
const path = require("path");
|
||||
const zlib = require("zlib");
|
||||
const amf3 = require("./amf3.js");
|
||||
const cdn = require("./cdn.js");
|
||||
@@ -13,15 +15,57 @@ const cdn = require("./cdn.js");
|
||||
// (DenItemHolder), and the CDN has no such files for these. each one's
|
||||
// sound sits inside a media file or a room file as an MP3 (a DefineSound
|
||||
// tag of a zlib-compressed SWF), so the file is cut out of there when a
|
||||
// client first asks for it. nothing of it is kept in this repository.
|
||||
// client first asks for it. nothing of it is kept in this repository,
|
||||
// except the tracks that are files of their own (`mp3`, in public/music/).
|
||||
|
||||
const FIRST_ID = 6001; // the official den items end at 5925
|
||||
const STRING_BASE = 9000100;
|
||||
const VOLUME = "40"; // the def's `flag`, as the official tracks have it
|
||||
const TEMPLATE = 614; // "Jam On": each new row starts as a copy of this track's
|
||||
|
||||
// music files from the game's development CDN that no den item plays,
|
||||
// kept in public/music/ and titled with their file names. tracks that
|
||||
// already are den items there under another name (the same audio, or the
|
||||
// same track by its name and length) were left out.
|
||||
const DEV_MUSIC = [
|
||||
"aj_BD_newTheme.mp3", "AJ_cinema_lobby.mp3", "AJ_CS_mus_over_flow.mp3", "aj_dr_musIntro.mp3", "aj_dr_musOutro.mp3",
|
||||
"aj_eat_em_up.mp3", "aj_fallingPhantoms.mp3", "aj_mus_BD_FullSpectrum.mp3", "aj_mus_BD_muffled.mp3",
|
||||
"aj_mus_BD_OceanFullSpectrum.mp3", "aj_mus_Best_Dressed1.mp3", "aj_mus_bestDressedOcean1.mp3",
|
||||
"aj_mus_bestDressedOceanMuffled.mp3", "aj_mus_carnival.mp3", "aj_mus_club.mp3", "AJ_mus_den_sitar.mp3",
|
||||
"aj_mus_dolphin.mp3", "AJ_mus_double_up.mp3", "aj_mus_flag_room.mp3", "AJ_mus_gem_ball.mp3",
|
||||
"aj_mus_gem_breaker.mp3", "aj_mus_hassel_hoff.mp3", "aj_mus_hedgehog.mp3", "aj_mus_horseRaceLP.mp3",
|
||||
"AJ_mus_jamaa_township.mp3", "aj_mus_oceans_shop.mp3", "AJ_Mus_Phantom_Fighter.mp3", "aj_mus_phantoms_treasure.mp3",
|
||||
"aj_mus_pillBug.mp3", "aj_mus_rare_item_shop.mp3", "aj_mus_shiveer_tent.mp3", "aj_mus_sorting_game.mp3",
|
||||
"AJ_Mus_spider_shooter.mp3", "aj_mus_Thierrys_aquarium.mp3", "aj_mus_touchPool.mp3", "AJ_mus_twister.mp3",
|
||||
"aj_mus_wolfParty.mp3", "aj_musBackToSchoolParty.mp3", "aj_musBestGuess.mp3", "aj_musChineseNewYear.mp3",
|
||||
"aj_musEagleLP.mp3", "aj_musHospital.mp3", "aj_musNewJammaIntro.mp3", "aj_musNPEintro.mp3", "aj_musOutback.mp3",
|
||||
"aj_musOutbackShop.mp3", "aj_musPhntmKingIntro.mp3", "aj_musSpotOn.mp3", "aj_musStingerRaceIntro.mp3",
|
||||
"aj_musStingerRaceOver.mp3", "aj_musTelescopeRoom.mp3", "aj_musVolcanoGreely.mp3", "AJ_Native_American.mp3",
|
||||
"aj_petshop_mus.mp3", "AJ_reggaeton.mp3", "AJ_Shopping_music.mp3", "ajm_musBossBattle25.mp3", "ajm_musCloud.mp3",
|
||||
"ajm_musFFFruitShack.mp3", "ajm_musFFSplash.mp3", "ajm_musFFTheater.mp3", "ajm_tugOfWar.mp3", "ajmusMasterp.mp3",
|
||||
"ajq_forbodingTheme.mp3", "ajq_MiraThemeFinal.mp3", "ajq_mus2PhntmKings.mp3", "ajq_musAdvent20Hub.mp3",
|
||||
"ajq_musBattleoftheForrest.mp3", "ajq_musbunnyBurrow.mp3", "ajq_musCave.mp3", "ajq_musCaveBossBattle.mp3",
|
||||
"ajq_musCaveSlides.mp3", "ajq_musCharge.mp3", "ajq_musCombat.mp3", "ajq_musCraftingVillage.mp3",
|
||||
"ajq_musDungeon.mp3", "ajq_musEerieGreelyCave.mp3", "ajq_musFactoryBossLp.mp3", "ajq_musFroggyMarsh.mp3",
|
||||
"ajq_musGraveyard.mp3", "ajq_musHauntedForest.mp3", "ajq_musInToDeep.mp3", "ajq_musIntotheCaves.mp3",
|
||||
"ajq_musMadGreely.mp3", "ajq_musMiraTomb.mp3", "ajq_musOceanQuest9.mp3", "ajq_musOuterLimits.mp3",
|
||||
"ajq_musPeckSafe.mp3", "ajq_musPecksSecret.mp3", "ajq_musPhntmCreepy.mp3", "ajq_musPhntmDiguise.mp3",
|
||||
"ajq_musPhntmInvasion.mp3", "ajq_musPhntmKingIntro.mp3", "ajq_musPhntmRetreat.mp3", "ajq_musPumpkinPatch.mp3",
|
||||
"ajq_musQ22FinalRoom.mp3", "ajq_musQuest.mp3", "ajq_musQuest19Cave.mp3", "ajq_musQuest22.mp3",
|
||||
"ajq_musQuest22B.mp3", "ajq_MusQuest23.mp3", "ajq_MusQuest23Intro.mp3", "ajq_musQuestStealth.mp3",
|
||||
"ajq_musRoofTop.mp3", "ajq_musSafeLP.mp3", "ajq_musScienceLab.mp3", "ajq_musSearch4GreelyLP.mp3",
|
||||
"ajq_musSirGilbertsCastle.mp3", "ajq_musSpooky.mp3", "ajq_musSpotted.mp3", "ajq_musSuspicious.mp3",
|
||||
"ajq_musTrainingForrest.mp3", "ajq_musTreeHutPlayful.mp3", "ajq_musTugOfWarIdleLP.mp3", "ajq_musTurningTheTide.mp3",
|
||||
"ajq_musTutorial.mp3", "ajq_musVolcanoFreeze.mp3", "ajq_musVolIn.mp3", "ajq_musVolOut.mp3", "ajq_musWinterFun.mp3",
|
||||
"ajw_musWildExplorers.mp3", "ajw_musWildExplorersTent.mp3", "astronomy_mus_think.mp3", "fs_mus_intro.mp3",
|
||||
"Mus_AP_Interface.mp3", "Mus_Art_Studio_theme.mp3", "MusAppondaleMuseum.mp3", "MusBirdsOfParadise.mp3",
|
||||
"MusDenDef.mp3", "TD_mus_120bpm_lp.mp3", "TD_mus_80bpm_lp.mp3", "TD_mus_80bpm_nw.mp3", "TD_mus_80bpm_we.mp3",
|
||||
];
|
||||
|
||||
// {file, title, sound: the sound's exported name ("" for the only, unnamed
|
||||
// one), and where it is: a media id, or a room file and the asset in it}
|
||||
// one), and where it is: a media id, or a room file and the asset in it, or
|
||||
// an MP3 of this server's own in public/music/ (`mp3`)}. new tracks go at the
|
||||
// end: a track's item id is its place in the list.
|
||||
const TRACKS = [
|
||||
{file: "XtraNarration", title: "Narration", media: 1904, sound: "Narration"},
|
||||
{file: "XtraUnnamed", title: "Unnamed Sound", media: 46, sound: ""},
|
||||
@@ -32,6 +76,8 @@ const TRACKS = [
|
||||
{file: "XtraVolcano", title: "Volcano", media: 2507, sound: "aj_musVolcanoFull"},
|
||||
...[1, 2, 3, 4].map(layer => ({file: `XtraConcert${layer}`, title: `Concert Layer ${layer}`,
|
||||
room: "party/venue_concert", asset: "Concert\\Concert_Party_Front_Lights.swf", sound: `layer${layer}`})),
|
||||
{file: "XtraDebugMusic", title: "AJ_Debug_Music.mp3", mp3: "AJ_Debug_Music.mp3"},
|
||||
...DEV_MUSIC.map(mp3 => ({file: `Xtra_${mp3.slice(0, -4)}`, title: mp3, mp3})),
|
||||
].map((track, index) => ({...track, id: FIRST_ID + index, stringId: STRING_BASE + index}));
|
||||
|
||||
const ids = TRACKS.map(track => track.id);
|
||||
@@ -87,7 +133,12 @@ const soundIn = (swf, name) => {
|
||||
return null;
|
||||
};
|
||||
|
||||
const MUSIC_DIR = path.join(__dirname, "..", "public", "music");
|
||||
|
||||
const extract = async track => {
|
||||
if (track.mp3) {
|
||||
return fs.promises.readFile(path.join(MUSIC_DIR, track.mp3));
|
||||
}
|
||||
if (track.media) {
|
||||
const swf = await cdn.get(cdn.hashedPath(`media/${track.media}`));
|
||||
return swf ? soundIn(swf, track.sound) : null;
|
||||
|
||||
+10
-6
@@ -73,6 +73,10 @@ const flashVars = () => ({
|
||||
startupRoom: config.startupRoom,
|
||||
// "-1" turns the client's stats socket off.
|
||||
sbStatTrackerIp: "-1",
|
||||
// the client's Discord rich presence (its app/discord.js): the Discord
|
||||
// application it shows as, "" for none, and where its button goes.
|
||||
discordAppId: config.discord.clientId,
|
||||
presenceUrl: `${config.siteUrl}download`,
|
||||
sbStatModulator: "0",
|
||||
currentTimestamp: Math.floor(Date.now() / 1000),
|
||||
country: "US",
|
||||
@@ -469,6 +473,7 @@ const renameAndSignIn = (res, body, from) => {
|
||||
console.log(`[accounts] a rejected username was replaced by "${logText(account.username)}"`);
|
||||
accounts.setLoginChoices(account, body.login_choices);
|
||||
const token = accounts.issueToken(account);
|
||||
devices.noteLauncher(token, Boolean(devices.read(body.device)));
|
||||
send(res, 200, {auth_token: token, refresh_token: token, device_token: entry.deviceToken});
|
||||
};
|
||||
|
||||
@@ -479,13 +484,11 @@ const authenticate = async (req, res, from) => {
|
||||
return;
|
||||
}
|
||||
// the computer it is on (lib/devices.js): a client that does not say is
|
||||
// out of date (before 1.3.0) or not ours. 1.2 shows "The server refused
|
||||
// the login (426)", and still offers its update.
|
||||
// out of date (before 1.3.0) or not ours. it is signed in all the same,
|
||||
// and its token noted (signInChecked): with config.requireDevice the game
|
||||
// then loads and its login popup says to update (lib/world.js), where a
|
||||
// refusal here only ever showed "The server refused the login (426)".
|
||||
const device = devices.read(body.device);
|
||||
if (!device && config.requireDevice) {
|
||||
send(res, 426, {error_code: 101, error: "client_outdated"});
|
||||
return;
|
||||
}
|
||||
const accountKey = String(body.username).trim().toLowerCase();
|
||||
if (!from.local && failuresByAddress.blocked(from.key)) {
|
||||
send(res, 429, {error_code: 429, error: "too_many_attempts"});
|
||||
@@ -609,6 +612,7 @@ const signInChecked = async (res, body, from, account, saved, device) => {
|
||||
// the custom client's advanced settings; the official launcher sends none.
|
||||
accounts.setLoginChoices(account, body.login_choices);
|
||||
const token = byRefresh ? body.refresh_token : accounts.issueToken(account);
|
||||
devices.noteLauncher(token, Boolean(device));
|
||||
send(res, 200, {auth_token: token, refresh_token: token, device_token: deviceToken});
|
||||
};
|
||||
|
||||
|
||||
+55
-9
@@ -12,6 +12,7 @@ const config = require("../config.js");
|
||||
const limits = require("./limits.js");
|
||||
const achievements = require("./achievements.js");
|
||||
const badges = require("./badges.js");
|
||||
const discord = require("./discord.js");
|
||||
const bans = require("./bans.js");
|
||||
const captcha = require("./captcha.js");
|
||||
const chatlog = require("./chatlog.js");
|
||||
@@ -40,6 +41,12 @@ const world = require("./world.js");
|
||||
const COOKIE = "ajc_account";
|
||||
// A device that gave its two-step code keeps this for 30 days (lib/totp.js).
|
||||
const DEVICE_COOKIE = "ajc_device";
|
||||
// a Discord link under way (lib/discord.js): the browser that started it
|
||||
// must be the one that comes back. Lax, as Discord's redirect back is from
|
||||
// another site, which the page's own (Strict) cookie is not sent from.
|
||||
const DISCORD_COOKIE = "ajc_dlink";
|
||||
const discordCookie = (value, maxAgeSeconds) =>
|
||||
`${DISCORD_COOKIE}=${value}; Path=/account/discord; HttpOnly; SameSite=Lax; Max-Age=${maxAgeSeconds}${config.secureCookies ? "; Secure" : ""}`;
|
||||
const SESSION_HOURS = 12;
|
||||
const TEN_MINUTES_MS = 600000;
|
||||
const MAX_NOTE = 120;
|
||||
@@ -104,6 +111,13 @@ const signOutOthers = (account, req) => {
|
||||
}
|
||||
};
|
||||
|
||||
// ends the account's sessions in the moderator panel (lib/modpanel.js, which
|
||||
// needs this file, so it is asked for when used): with the others when the
|
||||
// password changes or the owner signs out everywhere, and when the account
|
||||
// locks or turns 2FA off, so that a session from before does not come back
|
||||
// with it.
|
||||
const endStaffSessions = account => require("./modpanel.js").forget(account);
|
||||
|
||||
const twoStepOf = account => ({on: totp.isOn(account), since: account.totp ? account.totp.since : null,
|
||||
recoveryLeft: account.totp ? account.totp.recovery.length : 0, devices: totp.freshDevices(account).length, deviceDays: totp.DEVICE_DAYS});
|
||||
|
||||
@@ -164,6 +178,8 @@ const profile = (account, from) => {
|
||||
locked: account.locked,
|
||||
twoStep: twoStepOf(account),
|
||||
discord: account.discord,
|
||||
discordLinked: Boolean(account.discordId),
|
||||
discordLinking: discord.linking(),
|
||||
bio: account.bio,
|
||||
bioLimit: badges.MAX_BIO,
|
||||
badges: badges.of(account).map(badge => badge.label),
|
||||
@@ -283,6 +299,7 @@ const act = (account, body, req, from, res) => {
|
||||
}
|
||||
world.moderation.actions.kick(account);
|
||||
signOutOthers(account, req);
|
||||
endStaffSessions(account);
|
||||
console.log(`[account] "${logText(account.username)}" changed their password from ${logText(from.address)}`);
|
||||
return {ok: "Password changed."};
|
||||
}
|
||||
@@ -302,6 +319,7 @@ const act = (account, body, req, from, res) => {
|
||||
// out of the game now, and no saved sign-in gets back in.
|
||||
accounts.revokeTokens(account);
|
||||
world.moderation.actions.kick(account);
|
||||
endStaffSessions(account);
|
||||
}
|
||||
accounts.save(account);
|
||||
console.log(`[account] "${logText(account.username)}" ${logText(account.locked ? "locked" : "unlocked")} from ${logText(from.address)}`);
|
||||
@@ -355,6 +373,7 @@ const act = (account, body, req, from, res) => {
|
||||
}
|
||||
totp.turnOff(account);
|
||||
accounts.save(account);
|
||||
endStaffSessions(account);
|
||||
res.setHeader("Set-Cookie", cookieHeader("", 0, DEVICE_COOKIE));
|
||||
console.log(`[account] "${logText(account.username)}" turned two-step sign-in off from ${logText(from.address)}`);
|
||||
return {ok: "2FA is off."};
|
||||
@@ -403,16 +422,15 @@ const act = (account, body, req, from, res) => {
|
||||
account.playtimePublic = body.on === true;
|
||||
accounts.save(account);
|
||||
return {ok: account.playtimePublic ? "Others can see your playtime on your card." : "Your playtime is private."};
|
||||
// their Discord username, for their card in the game. empty takes it off.
|
||||
case "discord": {
|
||||
const name = badges.discordName(body.name);
|
||||
if (name === null) {
|
||||
return {error: "Not a Discord username."};
|
||||
// their Discord account, for their card in the game: it is linked by
|
||||
// signing in to Discord (GET /account/discord/link), and only taken off
|
||||
// here, with the booster badge it brought.
|
||||
case "discord":
|
||||
if (String(body.name || "") !== "") {
|
||||
return {error: "Link your Discord account instead."};
|
||||
}
|
||||
account.discord = name;
|
||||
accounts.save(account);
|
||||
return {ok: name ? "Saved." : "Removed."};
|
||||
}
|
||||
discord.unlink(account);
|
||||
return {ok: "Removed."};
|
||||
// the player's own words about a buddy; only they see them.
|
||||
case "buddyNote": {
|
||||
const key = String(body.name || "").toLowerCase();
|
||||
@@ -459,6 +477,7 @@ const act = (account, body, req, from, res) => {
|
||||
accounts.save(account);
|
||||
world.moderation.actions.kick(account);
|
||||
signOutOthers(account, req);
|
||||
endStaffSessions(account);
|
||||
return {ok: "Signed out everywhere."};
|
||||
// for good: the password again, and the username typed out.
|
||||
case "delete": {
|
||||
@@ -471,6 +490,7 @@ const act = (account, body, req, from, res) => {
|
||||
const name = account.username;
|
||||
world.disconnect(account);
|
||||
signOutOthers(account, null);
|
||||
endStaffSessions(account);
|
||||
erase(account);
|
||||
console.log(`[account] "${logText(name)}" deleted their account from ${logText(from.address)}`);
|
||||
return {ok: "Account deleted.", deleted: true};
|
||||
@@ -570,12 +590,38 @@ const handle = async (req, res, url, from, web) => {
|
||||
}
|
||||
}
|
||||
|
||||
// back from Discord (lib/discord.js): the state and the nonce must be the
|
||||
// ones the link began with. the page then says how it went.
|
||||
if (route === "GET /account/discord/callback") {
|
||||
const nonce = (new RegExp(`(?:^|;\\s*)${DISCORD_COOKIE}=([0-9a-f]{48})(?:;|$)`).exec(req.headers.cookie || "") || [])[1];
|
||||
const result = url.searchParams.get("error") ? {error: "cancelled"}
|
||||
: await discord.finish(url.searchParams.get("state"), nonce, url.searchParams.get("code"));
|
||||
res.setHeader("Set-Cookie", discordCookie("", 0));
|
||||
res.writeHead(302, {Location: `/account?discord=${result.ok ? "linked" : result.error}`});
|
||||
res.end();
|
||||
return;
|
||||
}
|
||||
|
||||
const account = signedInAs(req);
|
||||
if (!account) {
|
||||
reply(401, {error: "Sign in first."});
|
||||
return;
|
||||
}
|
||||
switch (route) {
|
||||
// the page's "Link Discord": off to Discord's sign-in, which comes back
|
||||
// to /account/discord/callback.
|
||||
case "GET /account/discord/link": {
|
||||
if (!discord.linking() || banFor(account, from)) {
|
||||
res.writeHead(302, {Location: "/account?discord=off"});
|
||||
res.end();
|
||||
return;
|
||||
}
|
||||
const {url: to, nonce} = discord.start(account);
|
||||
res.setHeader("Set-Cookie", discordCookie(nonce, 600));
|
||||
res.writeHead(302, {Location: to});
|
||||
res.end();
|
||||
return;
|
||||
}
|
||||
// A copy of their data, as a file. also from the page of a ban.
|
||||
case "GET /account/api/export":
|
||||
if (!writesPerTenMinutes.allow(account.id)) {
|
||||
|
||||
@@ -183,6 +183,34 @@ module.exports = ({findOnline}) => {
|
||||
return true;
|
||||
},
|
||||
|
||||
// every post they wrote on anyone's Jammer Wall (lib/walls.js), their
|
||||
// own included, and the replies to those, as deleting a post in the game
|
||||
// takes its replies. returns {posts, replies, walls}.
|
||||
clearWallPosts(author) {
|
||||
const changed = [];
|
||||
let posts = 0;
|
||||
let replies = 0;
|
||||
for (const owner of accounts.all()) {
|
||||
const {wall} = owner;
|
||||
const gone = new Set(wall.posts.filter(post => post.uid === author.id).map(post => post.x));
|
||||
if (!gone.size) {
|
||||
continue;
|
||||
}
|
||||
const kept = wall.posts.filter(post => !gone.has(post.x) && !gone.has(post.pp));
|
||||
posts += gone.size;
|
||||
replies += wall.posts.length - kept.length - gone.size;
|
||||
const left = new Set(kept.map(post => post.x));
|
||||
wall.posts = kept;
|
||||
wall.hidden = wall.hidden.filter(id => left.has(id));
|
||||
wall.modified = Date.now();
|
||||
changed.push(owner);
|
||||
}
|
||||
if (changed.length) {
|
||||
accounts.save(...changed);
|
||||
}
|
||||
return {posts, replies, walls: changed.length};
|
||||
},
|
||||
|
||||
grantGems(target, amount) {
|
||||
return actions.grantCurrency(target, CURRENCY_GEMS, amount, false);
|
||||
},
|
||||
|
||||
+84
-5
@@ -153,13 +153,16 @@ const maskedAddress = ban => ({
|
||||
|
||||
const wholeNumber = (value, min, max) => (Number.isInteger(value) && value >= min && value <= max ? value : null);
|
||||
|
||||
// the permission (lib/roles.js) each action needs.
|
||||
// the permission (lib/roles.js) each action needs. an action that is not
|
||||
// here is refused (act), so that a new one cannot go unchecked.
|
||||
const ACTION_PERMISSIONS = {
|
||||
ban: "player.ban", banReason: "player.ban", unban: "player.ban",
|
||||
silence: "chat.silence", unsilence: "chat.silence",
|
||||
kick: "player.kick", message: "player.warn", warn: "player.warn", unwarn: "player.warn",
|
||||
rejectName: "player.names", acceptName: "player.names", clearBio: "player.names",
|
||||
banAddress: "address.ban",
|
||||
clearWallPosts: "player.names", banAddress: "address.ban",
|
||||
// a computer's ban, as an address's, keeps out everyone who uses it
|
||||
banDevices: "address.ban", unbanDevices: "address.ban",
|
||||
summon: "player.summon", goto: "player.goto",
|
||||
note: "player.view", deleteNote: "player.view",
|
||||
};
|
||||
@@ -180,8 +183,11 @@ const act = (mod, target, body) => {
|
||||
if (!roles.outranks(mod, target)) {
|
||||
return {error: "Staff of your rank or above are for someone higher up to deal with."};
|
||||
}
|
||||
const permission = ACTION_PERMISSIONS[body.action];
|
||||
if (permission && !roles.can(mod, permission)) {
|
||||
const permission = Object.hasOwn(ACTION_PERMISSIONS, body.action) ? ACTION_PERMISSIONS[body.action] : null;
|
||||
if (!permission) {
|
||||
return {error: "Unknown action."};
|
||||
}
|
||||
if (!roles.can(mod, permission)) {
|
||||
return {error: "Your role cannot do that."};
|
||||
}
|
||||
switch (body.action) {
|
||||
@@ -256,6 +262,15 @@ const act = (mod, target, body) => {
|
||||
target.bio = "";
|
||||
accounts.save(target);
|
||||
return {ok: "Bio cleared."};
|
||||
case "clearWallPosts": {
|
||||
const {posts, replies, walls} = actions.clearWallPosts(target);
|
||||
if (!posts) {
|
||||
return {error: `${name} has no posts on any Jammer Wall.`};
|
||||
}
|
||||
const text = `${posts} wall ${posts === 1 ? "post" : "posts"} by ${name} removed from ${walls} ${walls === 1 ? "wall" : "walls"}`
|
||||
+ `${replies ? ` (with ${replies} ${replies === 1 ? "reply" : "replies"} to them)` : ""}.`;
|
||||
return {ok: text, detail: `${posts} posts, ${replies} replies, ${walls} walls`};
|
||||
}
|
||||
// a note for the other staff (lib/modnotes.js); the player never sees it.
|
||||
case "note": {
|
||||
const result = modNotes.add(target, by, body.text);
|
||||
@@ -412,6 +427,23 @@ const handle = async (req, res, url, from, web) => {
|
||||
}
|
||||
reply(result.ok ? 200 : 400, result.ok ? {ok: result.ok} : {error: result.error});
|
||||
};
|
||||
// a route's permission (lib/roles.js), as act() checks an action's: a
|
||||
// role without it is refused here, whatever its page shows.
|
||||
const may = permission => {
|
||||
if (roles.can(mod, permission)) {
|
||||
return true;
|
||||
}
|
||||
reply(403, {error: "Your role cannot do that."});
|
||||
return false;
|
||||
};
|
||||
// why the moderator may not act on `account`, as act() refuses: not on
|
||||
// themselves, nor on staff of their rank or above. null when they may.
|
||||
const refusalFor = account => {
|
||||
if (!account || roles.outranks(mod, account)) {
|
||||
return null;
|
||||
}
|
||||
return {error: account === mod ? "That is you." : "Staff of your rank or above are for someone higher up to deal with."};
|
||||
};
|
||||
|
||||
switch (route) {
|
||||
// who is signed in here, their role and what it allows: for a client to
|
||||
@@ -555,7 +587,12 @@ const handle = async (req, res, url, from, web) => {
|
||||
reply(200, {reports: reports.list(url.searchParams.get("handled") === "1"), open: reports.openCount()});
|
||||
return;
|
||||
|
||||
// a report dealt with: for the roles that act on players (a warning is
|
||||
// the least of it), not for one that only looks.
|
||||
case "POST /mod/api/report":
|
||||
if (!may("player.warn")) {
|
||||
return;
|
||||
}
|
||||
done(reports.markHandled(Number(body.id)) ? {ok: "Marked as dealt with."} : {error: "No such report waiting."}, "report dealt with", "", `#${Number(body.id)}`);
|
||||
return;
|
||||
|
||||
@@ -567,10 +604,32 @@ const handle = async (req, res, url, from, web) => {
|
||||
}
|
||||
case "POST /mod/api/request": {
|
||||
if (body.action === "appealApprove" || body.action === "appealDeny") {
|
||||
// a ban decision: for the roles that ban, and one that also lifts the
|
||||
// ban on an address only for those that ban addresses.
|
||||
const appeal = bans.waitingAppeal(body.id);
|
||||
const liftsAddress = body.action === "appealApprove" && appeal && appeal.addressKey && bans.addressBan(appeal.addressKey);
|
||||
if (!may("player.ban") || (liftsAddress && !may("address.ban"))) {
|
||||
return;
|
||||
}
|
||||
const refusal = appeal ? refusalFor(accounts.byId(appeal.accountId)) : null;
|
||||
if (refusal) {
|
||||
done(refusal);
|
||||
return;
|
||||
}
|
||||
const result = staff.answerAppeal(body.id, body.action === "appealApprove", body.reply, mod.username);
|
||||
done(result, body.action === "appealApprove" ? "appeal approved" : "appeal denied", result.username, bans.clean(body.reply, bans.MAX_REPLY));
|
||||
}
|
||||
else if (body.action === "approve" || body.action === "deny") {
|
||||
// a new name: for the roles that judge names.
|
||||
if (!may("player.names")) {
|
||||
return;
|
||||
}
|
||||
const request = support.nameRequestById(body.id);
|
||||
const refusal = request ? refusalFor(accounts.byId(request.accountId)) : null;
|
||||
if (refusal) {
|
||||
done(refusal);
|
||||
return;
|
||||
}
|
||||
const result = staff.answerNameRequest(body.id, body.action === "approve");
|
||||
done(result, body.action === "approve" ? "name request approved" : "name request denied", result.username);
|
||||
}
|
||||
@@ -594,8 +653,18 @@ const handle = async (req, res, url, from, web) => {
|
||||
return;
|
||||
}
|
||||
|
||||
// A device ban lifted (lib/devices.js).
|
||||
// A device ban lifted (lib/devices.js): for the roles that give them
|
||||
// (act's unbanDevices), and not one made with staff of their rank or above.
|
||||
case "POST /mod/api/device": {
|
||||
if (!may("address.ban")) {
|
||||
return;
|
||||
}
|
||||
const ban = devices.banById(body.id);
|
||||
const refusal = ban ? refusalFor(accounts.byId(ban.accountId)) : null;
|
||||
if (refusal) {
|
||||
done(refusal);
|
||||
return;
|
||||
}
|
||||
const result = staff.unbanDevices(body.id, mod.username);
|
||||
done(result, "hardware ban lifted", result.username || "");
|
||||
return;
|
||||
@@ -617,9 +686,19 @@ const handle = async (req, res, url, from, web) => {
|
||||
return;
|
||||
}
|
||||
|
||||
// a painting judged: for the roles that judge what players make, and
|
||||
// never their own or one by staff of their rank or above.
|
||||
case "POST /mod/api/masterpiece": {
|
||||
if (!may("items.approve")) {
|
||||
return;
|
||||
}
|
||||
const id = String(body.id || "");
|
||||
const maker = masterpieces.creatorOf(id);
|
||||
const refusal = refusalFor(maker);
|
||||
if (refusal) {
|
||||
done(refusal);
|
||||
return;
|
||||
}
|
||||
const result = body.action === "approve"
|
||||
? (world.approveMasterpiece(id) ? {ok: "Approved."} : {error: "No such painting waiting."})
|
||||
: body.action === "reject" || body.action === "remove"
|
||||
|
||||
+15
-8
@@ -8,6 +8,7 @@ const accounts = require("./accounts.js");
|
||||
const achievements = require("./achievements.js");
|
||||
const adopt = require("./adopt.js");
|
||||
const badges = require("./badges.js");
|
||||
const discordLinks = require("./discord.js");
|
||||
const bans = require("./bans.js");
|
||||
const colours = require("./colours.js");
|
||||
const chatlog = require("./chatlog.js");
|
||||
@@ -452,16 +453,13 @@ const act = (account, body) => {
|
||||
world.checkNameTag(account);
|
||||
return {ok: account.badges.length ? `${name} has: ${badges.of(account).map(badge => badge.label).join(", ")}.` : `${name} has no badges.`};
|
||||
}
|
||||
// their Discord username, which they otherwise set on the account
|
||||
// page; empty takes it off.
|
||||
// their linked Discord account (lib/discord.js), taken off.
|
||||
case "discord": {
|
||||
const discord = badges.discordName(body.name);
|
||||
if (discord === null) {
|
||||
return {error: "Not a Discord username."};
|
||||
// only taken off: a player links their own (lib/discord.js)
|
||||
if (String(body.name || "") !== "") {
|
||||
return {error: "Players link their Discord themselves, on the account page."};
|
||||
}
|
||||
account.discord = discord;
|
||||
accounts.save(account);
|
||||
return {ok: discord ? `Discord set to "${discord}".` : "Discord cleared."};
|
||||
return discordLinks.unlink(account) ? {ok: "Discord unlinked."} : {error: `${name} has no Discord linked.`};
|
||||
}
|
||||
// their bio, which they otherwise write on the account page; empty
|
||||
// takes it off.
|
||||
@@ -572,6 +570,15 @@ const act = (account, body) => {
|
||||
case "clearDen":
|
||||
actions.clearDen(account);
|
||||
return {ok: `Everything in ${name}'s den went back to their inventory.`};
|
||||
case "clearWallPosts": {
|
||||
const {posts, replies, walls} = actions.clearWallPosts(account);
|
||||
if (!posts) {
|
||||
return {error: `${name} has no posts on any Jammer Wall.`};
|
||||
}
|
||||
const text = `${posts} wall ${posts === 1 ? "post" : "posts"} by ${name} removed from ${walls} ${walls === 1 ? "wall" : "walls"}`
|
||||
+ `${replies ? ` (with ${replies} ${replies === 1 ? "reply" : "replies"} to them)` : ""}.`;
|
||||
return {ok: text, detail: `${posts} posts, ${replies} replies, ${walls} walls`};
|
||||
}
|
||||
case "gems": {
|
||||
const amount = wholeNumber(body.amount, -MAX_GEMS, MAX_GEMS);
|
||||
if (amount === null) {
|
||||
|
||||
+4
-4
@@ -17,15 +17,15 @@ const totp = require("./totp.js");
|
||||
const PERMISSIONS = {
|
||||
"player.view": "see players, chat, reports, requests, bans and paintings in the moderator panel, and keep notes on players (!note, !notes)",
|
||||
"staff.list": "see which staff are online (!staff)",
|
||||
"player.warn": "warn a player, take a warning back and send them a message (!warn, !unwarn, !warnings, !message)",
|
||||
"player.warn": "warn a player, take a warning back, send them a message and mark a report dealt with (!warn, !unwarn, !warnings, !message)",
|
||||
"player.goto": "go to the room a player is in (!goto)",
|
||||
"chat.silence": "silence and unsilence a player (!silence)",
|
||||
"player.kick": "disconnect a player (!kick)",
|
||||
"player.summon": "bring a player to the room you are in (!summon)",
|
||||
"staff.invisible": "go unseen in rooms, as the game's moderators could (!invisible)",
|
||||
"player.ban": "ban, unban and change a ban's reason",
|
||||
"player.names": "reject or accept a name, clear a bio",
|
||||
"address.ban": "ban the address a player last signed in from",
|
||||
"player.ban": "ban, unban, change a ban's reason and answer ban appeals",
|
||||
"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",
|
||||
"items.approve": "approve or turn away the items and pictures players make, when the admin has asked for that",
|
||||
"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)",
|
||||
};
|
||||
|
||||
+47
-3
@@ -146,6 +146,11 @@ const MAX_USER_VARS = 2000;
|
||||
const MAX_FILTER_WORDS = 100; // a player's own words for their chat filter
|
||||
const MAX_FILTER_WORD = 30;
|
||||
const LOGIN_BANNED = -15; // MainFrame.MSG_ID_LOGIN_BANNED
|
||||
// MainFrame.MSG_ID_LOGIN_ACCT_MAINT: its popup (GamePlay.onWorldLogIn) shows
|
||||
// localization string 11198, which lib/defpacks.js makes the "update your
|
||||
// client" message. the official servers' account maintenance never happens
|
||||
// here.
|
||||
const LOGIN_OUTDATED = -12;
|
||||
|
||||
const THEME_PATH_PREFIX = "theme_"; // lib/http.js looks for this
|
||||
const chatLines = limits.limiter(config.chatLinesPerWindow, config.chatWindowMs);
|
||||
@@ -183,6 +188,26 @@ const sees = (viewer, subject) => (!subject.invisible || roles.isActiveStaff(vie
|
||||
const watchers = session => others(session).filter(other => sees(other, session));
|
||||
const TYPING_EVERY_MS = 2000; // "typing" passed on at most this often per player (xty)
|
||||
|
||||
// tags ("@name") in chat and on Jammer Walls (xmn): the longest player's
|
||||
// name that the text after an "@" starts with, ending where a word does
|
||||
// ("@John Smith hi" is John Smith if there is one, else John; "@Bobby" is
|
||||
// never Bob). {length, name} or null.
|
||||
const MAX_MENTION_TEXT = 40;
|
||||
const MAX_MENTIONS = 10; // per question
|
||||
const mentionLookups = limits.limiter(120, 60000); // questions a minute, per player
|
||||
const mentionOf = text => {
|
||||
for (let length = Math.min(text.length, MAX_MENTION_TEXT); length > 0; length--) {
|
||||
if (length < text.length && /[A-Za-z0-9]/.test(text[length])) {
|
||||
continue;
|
||||
}
|
||||
const name = accounts.nameOf(text.slice(0, length));
|
||||
if (name) {
|
||||
return {length, name};
|
||||
}
|
||||
}
|
||||
return null;
|
||||
};
|
||||
|
||||
const decodeEntities = text => text
|
||||
.replace(/</g, "<")
|
||||
.replace(/>/g, ">")
|
||||
@@ -304,9 +329,12 @@ const login = (session, msg) => {
|
||||
loginFailed(session, LOGIN_BANNED, "Banned");
|
||||
return;
|
||||
}
|
||||
if (config.requireDevice && devices.knownFor(account).lastAt < Math.floor(Date.now() / 1000) - 90 * 86400) {
|
||||
console.log(`[world] login rejected for "${logText(account.username)}": no device ids`);
|
||||
loginFailed(session, 0, "Update the client");
|
||||
// a launcher that sent no device ids (before 1.3.0): signed in at
|
||||
// /authenticate, refused here, where the game's popup can say why.
|
||||
if (config.requireDevice && (devices.launcherOutdated(msg.cdata("pword"))
|
||||
|| devices.knownFor(account).lastAt < Math.floor(Date.now() / 1000) - 90 * 86400)) {
|
||||
console.log(`[world] login rejected for "${logText(account.username)}": client outdated (no device ids)`);
|
||||
loginFailed(session, LOGIN_OUTDATED, "Client outdated");
|
||||
return;
|
||||
}
|
||||
// its username was rejected (lib/moderation.js): a new one first, which
|
||||
@@ -912,6 +940,22 @@ const handlers = {
|
||||
}
|
||||
},
|
||||
|
||||
// the patched client's tags (AJClient.resolveMentions): xmn [id, the text
|
||||
// after each "@", ...] -> "xmn" [.., .., id, then for each text: how many
|
||||
// of its characters are a player's name (0 for none), the name as it is
|
||||
// spelled, 1 if they are online]. what a text is not a name of stays text.
|
||||
xmn(session, roomId, [id, ...texts]) {
|
||||
if (!mentionLookups.allow(session.account.id)) {
|
||||
return;
|
||||
}
|
||||
const reply = [];
|
||||
for (const text of texts.slice(0, MAX_MENTIONS)) {
|
||||
const found = mentionOf(String(text));
|
||||
reply.push(found ? found.length : 0, found ? found.name : "", found && findOnline(found.name) ? 1 : 0);
|
||||
}
|
||||
session.sendXt("xmn", -1, Number.isInteger(Number(id)) ? Number(id) : 0, ...reply);
|
||||
},
|
||||
|
||||
// the patched client's staff window: going invisible, or being seen again.
|
||||
xiv(session) {
|
||||
if (session.invisible || roles.can(session.account, "staff.invisible")) {
|
||||
|
||||
+31
-16
@@ -367,12 +367,10 @@
|
||||
<section>
|
||||
<h2>Discord</h2>
|
||||
<p id="badges" hidden></p>
|
||||
<form id="discord-form">
|
||||
<label for="discord-name">Username</label>
|
||||
<input id="discord-name" maxlength="33" autocomplete="off" spellcheck="false">
|
||||
<div class="row"><button class="primary" type="submit">Save</button>
|
||||
<button id="discord-remove" type="button">Remove</button></div>
|
||||
</form>
|
||||
<p id="discord-shown"></p>
|
||||
<p class="hint" id="discord-about">Shown on your card in the game. Sign in to Discord to link your account; boosting Burrow's Discord server gives you the Server Booster badge while you boost.</p>
|
||||
<div class="row"><button class="primary" id="discord-link" type="button">Link Discord</button>
|
||||
<button id="discord-remove" type="button">Unlink</button></div>
|
||||
<p class="status" id="discord-status" role="status"></p>
|
||||
</section>
|
||||
|
||||
@@ -805,11 +803,11 @@
|
||||
$("bio-text").maxLength = account.bioLimit + 20; // room for the line ends a browser counts double
|
||||
$("bio-remove").hidden = !account.bio;
|
||||
bioCount();
|
||||
// not while it is being typed in: every answer from the server draws the page again.
|
||||
if (document.activeElement !== $("discord-name")) {
|
||||
$("discord-name").value = account.discord;
|
||||
}
|
||||
$("discord-remove").hidden = !account.discord;
|
||||
// linked by signing in to Discord (lib/discord.js), not typed in
|
||||
$("discord-shown").textContent = account.discordLinked ? `Linked: ${account.discord}` : "Not linked.";
|
||||
$("discord-link").textContent = account.discordLinked ? "Link another" : "Link Discord";
|
||||
$("discord-link").hidden = !account.discordLinking;
|
||||
$("discord-remove").hidden = !account.discordLinked;
|
||||
$("badges").hidden = account.badges.length === 0;
|
||||
$("badges").textContent = `Badges: ${account.badges.join(", ")}`;
|
||||
|
||||
@@ -938,6 +936,11 @@
|
||||
if (result.ok) {
|
||||
account = result.data;
|
||||
render();
|
||||
// back from linking Discord: how it went, once
|
||||
if (discordResult && Object.hasOwn(DISCORD_RESULTS, discordResult)) {
|
||||
setStatus("discord-status", DISCORD_RESULTS[discordResult], discordResult !== "linked");
|
||||
history.replaceState(null, "", location.pathname + location.hash);
|
||||
}
|
||||
}
|
||||
else {
|
||||
showGate(result.status === 0 ? result.data.error : "");
|
||||
@@ -1340,12 +1343,24 @@
|
||||
});
|
||||
$("bio-remove").addEventListener("click", () => act({action: "bio", text: ""}, "bio-status"));
|
||||
|
||||
$("discord-form").addEventListener("submit", async event => {
|
||||
event.preventDefault();
|
||||
$("discord-name").blur();
|
||||
await act({action: "discord", name: $("discord-name").value}, "discord-status");
|
||||
// off to Discord's sign-in; it comes back to /account?discord=<how it went>
|
||||
$("discord-link").addEventListener("click", () => {
|
||||
location.href = "/account/discord/link";
|
||||
});
|
||||
$("discord-remove").addEventListener("click", () => act({action: "discord", name: ""}, "discord-status"));
|
||||
$("discord-remove").addEventListener("click", () => {
|
||||
if (confirm("Unlink your Discord account? It comes off your card, and so does the Server Booster badge.")) {
|
||||
act({action: "discord", name: ""}, "discord-status");
|
||||
}
|
||||
});
|
||||
const DISCORD_RESULTS = {
|
||||
linked: "Discord linked.",
|
||||
cancelled: "Linking was cancelled.",
|
||||
expired: "That took too long, or was started in another browser. Try again.",
|
||||
taken: "That Discord account is linked to another Burrow account.",
|
||||
discord: "Discord did not answer. Try again later.",
|
||||
off: "Linking Discord is not available right now.",
|
||||
};
|
||||
const discordResult = new URLSearchParams(location.search).get("discord");
|
||||
|
||||
$("lock").addEventListener("click", () => {
|
||||
if (!account.locked && !window.confirm("Lock the account? Nobody gets in until you unlock it here.")) {
|
||||
|
||||
+19
-4
@@ -503,8 +503,9 @@
|
||||
<h3>Badges</h3>
|
||||
<div class="buttons" id="badge-boxes"></div>
|
||||
<div class="row" style="margin-top:8px"><button type="button" data-action="badges">Set</button></div>
|
||||
<div class="row" style="margin-top:8px"><input id="discord-name" maxlength="33" placeholder="Discord username" autocomplete="off" spellcheck="false" aria-label="Discord username">
|
||||
<button type="button" data-action="discord">Set</button></div>
|
||||
<div class="row" style="margin-top:8px" title="Players link their Discord themselves, on the account page">
|
||||
<span class="hint" id="discord-name"></span>
|
||||
<button type="button" data-action="discord">Unlink Discord</button></div>
|
||||
</div>
|
||||
<div class="action">
|
||||
<h3>Ban</h3>
|
||||
@@ -576,6 +577,7 @@
|
||||
</select>
|
||||
<button type="button" data-action="role">Set role</button>
|
||||
<button type="button" data-action="clearDen">Clear den</button>
|
||||
<button type="button" data-action="clearWallPosts" title="Every post they wrote on anyone's Jammer Wall, and the replies to those">Clear wall posts</button>
|
||||
<button type="button" data-action="delete" class="danger">Delete</button>
|
||||
</div>
|
||||
</div>
|
||||
@@ -1440,7 +1442,7 @@
|
||||
label.append(box, ` ${badge.label}`);
|
||||
return label;
|
||||
}));
|
||||
$("discord-name").value = current ? current.discord : "";
|
||||
$("discord-name").textContent = current && current.discord ? `Discord: ${current.discord}` : "No Discord linked";
|
||||
$("bio-text").value = current ? current.bio : "";
|
||||
$("quest-level").value = current ? current.level : "";
|
||||
$("ban-reason").value = current ? current.banReason : "";
|
||||
@@ -1628,7 +1630,7 @@
|
||||
case "gems": return {amount: numberFrom("gems-amount")};
|
||||
case "gift": return giftBody();
|
||||
case "badges": return {badges: [...$("badge-boxes").querySelectorAll("input:checked")].map(box => box.value)};
|
||||
case "discord": return {name: $("discord-name").value};
|
||||
case "discord": return {name: ""};
|
||||
case "bio": return {text: $("bio-text").value};
|
||||
case "level": return {level: numberFrom("quest-level")};
|
||||
default: return {};
|
||||
@@ -1658,6 +1660,9 @@
|
||||
if (action === "unbanDevices" && !window.confirm(`Lift the hardware bans on ${selected}?`)) {
|
||||
return;
|
||||
}
|
||||
if (action === "clearWallPosts" && !window.confirm(`Remove every post ${selected} wrote on any Jammer Wall, and the replies to them? This cannot be undone.`)) {
|
||||
return;
|
||||
}
|
||||
if (action === "banDevices" && !window.confirm(`Hardware ban ${selected}? Everyone on their hardware is put out.`)) {
|
||||
return;
|
||||
}
|
||||
@@ -1999,10 +2004,16 @@
|
||||
el("div", `${when(painting.createdAt)}${painting.status === "approved" ? `, ${painting.likes} like${painting.likes === 1 ? "" : "s"}` : ""}`
|
||||
+ `${which === "all" ? (painting.status === "waiting" ? " · waiting" : " · approved") : ""}`, "hint"));
|
||||
const buttons = el("div", undefined, "buttons");
|
||||
// rejecting or removing asks first; approving does not
|
||||
const sure = action => action === "approve" || confirm(action === "reject"
|
||||
? `Reject this painting by ${painting.creator}?` : `Remove this painting by ${painting.creator} from show?`);
|
||||
const button = (label, action, className) => {
|
||||
const node = el("button", label, className);
|
||||
node.type = "button";
|
||||
node.addEventListener("click", async () => {
|
||||
if (!sure(action)) {
|
||||
return;
|
||||
}
|
||||
node.disabled = true;
|
||||
const result = await api("masterpiece", {id: painting.id, action});
|
||||
setStatus($("masterpiece-status"), result.data.ok || result.data.error || "That did not work.", !result.ok);
|
||||
@@ -2335,6 +2346,10 @@
|
||||
el("div", `by ${entry.maker} · ${when(entry.createdAt)}${entry.makerStrikes ? ` · ${entry.makerStrikes} of ${data.strikes} pictures turned away before` : ""}`, "hint"));
|
||||
const buttons = el("div", undefined, "buttons");
|
||||
const decide = approve => async () => {
|
||||
// turning away asks first; approving does not
|
||||
if (!approve && !confirm(`Turn away ${entry.waiting === "item" ? "the item" : "the picture of"} "${entry.name}" by ${entry.maker}?`)) {
|
||||
return;
|
||||
}
|
||||
const result = await api("review", {kind: entry.kind, id: entry.id, approve});
|
||||
setStatus($("review-status"), said(result), !result.ok);
|
||||
await refresh();
|
||||
|
||||
@@ -84,6 +84,12 @@
|
||||
}
|
||||
}
|
||||
|
||||
// where the player is, for the client's Discord rich presence
|
||||
// (AJClient.presenceRoom): a short line such as "In Jamaa Township".
|
||||
function ajPresence(text) {
|
||||
window.ipc.sendToHost("presence", String(text).slice(0, 100));
|
||||
}
|
||||
|
||||
function ajPrint(imageData) {
|
||||
window.ipc.sendToHost("printImage", imageData);
|
||||
}
|
||||
|
||||
+52
-25
@@ -477,11 +477,13 @@
|
||||
<button type="button" data-action="goto">Go to them</button></div>
|
||||
</div>
|
||||
<div class="action">
|
||||
<h3>Username and bio</h3>
|
||||
<h3>Username, bio and wall posts</h3>
|
||||
<div class="row">
|
||||
<button type="button" data-action="rejectName" class="danger">Reject username</button>
|
||||
<button type="button" data-action="acceptName">Take back</button>
|
||||
<button type="button" data-action="clearBio">Clear bio</button></div>
|
||||
<div class="row" style="margin-top:8px" title="Every post they wrote on anyone's Jammer Wall, and the replies to those">
|
||||
<button type="button" data-action="clearWallPosts" class="danger">Clear wall posts</button></div>
|
||||
</div>
|
||||
</div>
|
||||
<h3 style="margin:16px 0 4px">Other accounts</h3>
|
||||
@@ -1117,6 +1119,7 @@
|
||||
unbanDevices: name => `Lift the hardware bans on ${name}?`,
|
||||
rejectName: name => `Reject the username ${name}? They are signed out and must pick another.`,
|
||||
unwarn: name => `Take back ${name}'s latest warning?`,
|
||||
clearWallPosts: name => `Remove every post ${name} wrote on any Jammer Wall, and the replies to them? This cannot be undone.`,
|
||||
};
|
||||
|
||||
$("detail").addEventListener("click", async event => {
|
||||
@@ -1292,7 +1295,7 @@
|
||||
if (handled) {
|
||||
box.append(el("div", `Dealt with on ${when(report.handledAt)}`, "hint"));
|
||||
}
|
||||
else {
|
||||
else if (permissions.has("player.warn")) {
|
||||
buttons.append(button("Dealt with", async () => {
|
||||
const result = await api("report", {id: report.id});
|
||||
setStatus($("report-status"), said(result), !result.ok);
|
||||
@@ -1339,9 +1342,17 @@
|
||||
reply.setAttribute("aria-label", `Reply to ${appeal.username}`);
|
||||
reply.style.width = "100%";
|
||||
const buttons = el("div", undefined, "buttons");
|
||||
buttons.append(button("Unban", () => answer({action: "appealApprove", id: appeal.accountId, reply: reply.value}), "primary"),
|
||||
button("Deny", () => answer({action: "appealDeny", id: appeal.accountId, reply: reply.value})),
|
||||
button("Player", () => openPlayer(appeal.username)), button("Chat history", () => openChat(appeal.username)));
|
||||
// answering is a ban decision, and lifting an address's ban with
|
||||
// it is for the roles that ban addresses (lib/modpanel.js).
|
||||
const answers = permissions.has("player.ban");
|
||||
if (answers && (!appeal.ofAddress || permissions.has("address.ban"))) {
|
||||
buttons.append(button("Unban", () => answer({action: "appealApprove", id: appeal.accountId, reply: reply.value}), "primary"));
|
||||
}
|
||||
if (answers) {
|
||||
buttons.append(button("Deny", () => answer({action: "appealDeny", id: appeal.accountId, reply: reply.value})));
|
||||
}
|
||||
buttons.append(button("Player", () => openPlayer(appeal.username)), button("Chat history", () => openChat(appeal.username)));
|
||||
reply.hidden = !answers;
|
||||
box.append(reply, buttons);
|
||||
return box;
|
||||
}));
|
||||
@@ -1356,7 +1367,7 @@
|
||||
if (handled) {
|
||||
box.append(el("div", `${request.status === "approved" ? "Approved" : "Denied"} on ${when(request.handledAt)}`, "hint"));
|
||||
}
|
||||
else {
|
||||
else if (permissions.has("player.names")) {
|
||||
const buttons = el("div", undefined, "buttons");
|
||||
buttons.append(button("Approve", () => answer({action: "approve", id: request.id}), "primary"), button("Deny", () => answer({action: "deny", id: request.id})));
|
||||
box.append(buttons);
|
||||
@@ -1404,16 +1415,22 @@
|
||||
box.append(picture, el("h3", painting.creator),
|
||||
el("div", `${when(painting.createdAt)}${which === "all" ? (painting.status === "waiting" ? " · waiting" : " · on show") : ""}`, "hint"));
|
||||
const buttons = el("div", undefined, "buttons");
|
||||
// rejecting or removing asks first; approving does not
|
||||
const sure = action => action === "approve" || confirm(action === "reject"
|
||||
? `Reject this painting by ${painting.creator}?` : `Remove this painting by ${painting.creator} from show?`);
|
||||
const does = (label, action, className) => button(label, async () => {
|
||||
if (!sure(action)) {
|
||||
return;
|
||||
}
|
||||
const result = await api("masterpiece", {id: painting.id, action});
|
||||
setStatus($("masterpiece-status"), said(result), !result.ok);
|
||||
refresh();
|
||||
}, className);
|
||||
if (painting.status === "waiting") {
|
||||
buttons.append(does("Approve", "approve", "primary"), does("Reject", "reject", "danger"));
|
||||
}
|
||||
else {
|
||||
buttons.append(does("Remove", "remove", "danger"));
|
||||
// judging paintings is for the roles that judge what players make
|
||||
if (permissions.has("items.approve")) {
|
||||
buttons.append(...(painting.status === "waiting"
|
||||
? [does("Approve", "approve", "primary"), does("Reject", "reject", "danger")]
|
||||
: [does("Remove", "remove", "danger")]));
|
||||
}
|
||||
buttons.append(button("Player", () => openPlayer(painting.creator)));
|
||||
box.append(buttons);
|
||||
@@ -1458,11 +1475,13 @@
|
||||
$("addresses").replaceChildren(...data.addresses.map(ban => {
|
||||
const row = el("tr");
|
||||
const buttons = el("td");
|
||||
buttons.append(button("Unban", async () => {
|
||||
const result = await api("address", {id: ban.id});
|
||||
setStatus($("ban-status"), said(result), !result.ok);
|
||||
refresh();
|
||||
}));
|
||||
if (permissions.has("address.ban")) {
|
||||
buttons.append(button("Unban", async () => {
|
||||
const result = await api("address", {id: ban.id});
|
||||
setStatus($("ban-status"), said(result), !result.ok);
|
||||
refresh();
|
||||
}));
|
||||
}
|
||||
row.append(el("td", ban.address), el("td", ban.reason), el("td", ban.by || "—"), el("td", when(ban.createdAt)), buttons);
|
||||
return row;
|
||||
}));
|
||||
@@ -1470,14 +1489,17 @@
|
||||
$("device-bans").replaceChildren(...data.devices.map(ban => {
|
||||
const row = el("tr");
|
||||
const buttons = el("td");
|
||||
buttons.append(button("Unban", async () => {
|
||||
if (!window.confirm(`Lift the hardware ban made with ${ban.username}?`)) {
|
||||
return;
|
||||
}
|
||||
const result = await api("device", {id: ban.id});
|
||||
setStatus($("ban-status"), said(result), !result.ok);
|
||||
refresh();
|
||||
}), " ", button("Player", () => openPlayer(ban.username)));
|
||||
if (permissions.has("address.ban")) {
|
||||
buttons.append(button("Unban", async () => {
|
||||
if (!window.confirm(`Lift the hardware ban made with ${ban.username}?`)) {
|
||||
return;
|
||||
}
|
||||
const result = await api("device", {id: ban.id});
|
||||
setStatus($("ban-status"), said(result), !result.ok);
|
||||
refresh();
|
||||
}), " ");
|
||||
}
|
||||
buttons.append(button("Player", () => openPlayer(ban.username)));
|
||||
row.append(el("td", ban.username || "—"), el("td", ban.reason), el("td", ban.by || "—"), el("td", when(ban.createdAt)),
|
||||
deviceAccounts(ban.accounts), deviceIds(ban), buttons);
|
||||
return row;
|
||||
@@ -1843,6 +1865,10 @@
|
||||
el("div", `by ${entry.maker} · ${when(entry.createdAt)}${entry.makerStrikes ? ` · ${entry.makerStrikes} of ${data.strikes} pictures turned away before` : ""}`, "hint"));
|
||||
const buttons = el("div", undefined, "buttons");
|
||||
const decide = approve => async () => {
|
||||
// turning away asks first; approving does not
|
||||
if (!approve && !confirm(`Turn away ${entry.waiting === "item" ? "the item" : "the picture of"} "${entry.name}" by ${entry.maker}?`)) {
|
||||
return;
|
||||
}
|
||||
const result = await api("review", {kind: entry.kind, id: entry.id, approve});
|
||||
setStatus($("review-status"), said(result), !result.ok);
|
||||
await refresh();
|
||||
@@ -2095,7 +2121,8 @@
|
||||
silence: "chat.silence", unsilence: "chat.silence",
|
||||
kick: "player.kick", message: "player.warn", warn: "player.warn", unwarn: "player.warn",
|
||||
rejectName: "player.names", acceptName: "player.names", clearBio: "player.names",
|
||||
banAddress: "address.ban", summon: "player.summon", goto: "player.goto",
|
||||
clearWallPosts: "player.names", banAddress: "address.ban", banDevices: "address.ban", unbanDevices: "address.ban",
|
||||
summon: "player.summon", goto: "player.goto",
|
||||
};
|
||||
const applyPermissions = async () => {
|
||||
const result = await api("me");
|
||||
|
||||
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Loaded 100 of 174 files, more files were not shown because too many files have changed in this diff.
Show more
Reference in new issue
Block a user