Merge branch 'master' into newnav

This commit is contained in:
Miodec 2022-09-04 20:04:08 +02:00
commit 283c2773c5
5 changed files with 22 additions and 24 deletions

View file

@ -34,6 +34,7 @@ import * as George from "../../tasks/george";
import { getDailyLeaderboard } from "../../utils/daily-leaderboards";
import AutoRoleList from "../../constants/auto-roles";
import * as UserDAL from "../../dal/user";
import { buildMonkeyMail } from "../../utils/monkey-mail";
try {
if (anticheatImplemented() === false) throw new Error("undefined");
@ -248,11 +249,24 @@ export async function addResult(
//autoban
const autoBanConfig = req.ctx.configuration.users.autoBan;
if (autoBanConfig.enabled) {
await recordAutoBanEvent(
const didUserGetBanned = await recordAutoBanEvent(
uid,
autoBanConfig.maxCount,
autoBanConfig.maxHours
);
if (didUserGetBanned) {
const mail = buildMonkeyMail({
getTemplate: () => ({
subject: "Banned",
body: "Your account has been automatically banned for triggering the anticheat system. If you believe this is a mistake, please contact support.",
}),
});
UserDAL.addToInbox(
uid,
[mail],
req.ctx.configuration.users.inbox.maxMail
);
}
}
const status = MonkeyStatusCodes.BOT_DETECTED;
throw new MonkeyError(status.code, "Possible bot detected");
@ -452,7 +466,7 @@ async function calculateXp(
let modifier = 1;
const correctedEverything = charStats
.slice(2)
.slice(1)
.every((charStat: number) => charStat === 0);
if (acc === 100) {

View file

@ -681,10 +681,12 @@ export async function recordAutoBanEvent(
uid: string,
maxCount: number,
maxHours: number
): Promise<void> {
): Promise<boolean> {
const user = await getUser(uid, "record auto ban event");
if (user.banned) return;
let ret = false;
if (user.banned) return ret;
const autoBanTimestamps = user.autoBanTimestamps ?? [];
@ -704,10 +706,12 @@ export async function recordAutoBanEvent(
};
if (recentAutoBanTimestamps.length > maxCount) {
updateObj.banned = true;
ret = true;
}
await getUsersCollection().updateOne({ uid }, { $set: updateObj });
Logger.logToDb("user_auto_banned", { autoBanTimestamps }, uid);
return ret;
}
export async function updateProfile(

View file

@ -39,7 +39,6 @@
"@types/tinycolor2": "1.4.3",
"buffer": "6.0.3",
"circular-dependency-plugin": "5.2.2",
"clean-terminal-webpack-plugin": "3.0.0",
"copy-webpack-plugin": "10.2.4",
"css-loader": "6.7.1",
"css-minimizer-webpack-plugin": "3.4.1",
@ -2769,15 +2768,6 @@
"node": ">=6"
}
},
"node_modules/clean-terminal-webpack-plugin": {
"version": "3.0.0",
"resolved": "https://registry.npmjs.org/clean-terminal-webpack-plugin/-/clean-terminal-webpack-plugin-3.0.0.tgz",
"integrity": "sha512-wcgkQZmwEWYYjHblXc0+UGFDtx37S+1qgUQl4EOhhinzSHbZpixWBiasQ91RoCMf5lAm67j1XOt9z+HN+sWkWA==",
"dev": true,
"peerDependencies": {
"webpack": "^4.0.0 || ^5.0.0"
}
},
"node_modules/cli-boxes": {
"version": "2.2.1",
"resolved": "https://registry.npmjs.org/cli-boxes/-/cli-boxes-2.2.1.tgz",
@ -16635,13 +16625,6 @@
"resolved": "https://registry.npmjs.org/clean-stack/-/clean-stack-2.2.0.tgz",
"integrity": "sha512-4diC9HaTE+KRAMWhDhrGOECgWZxoevMc5TlkObMqNSsVU62PYzXZ/SMTjzyGAFF1YusgxGcSWTEXBhp0CPwQ1A=="
},
"clean-terminal-webpack-plugin": {
"version": "3.0.0",
"resolved": "https://registry.npmjs.org/clean-terminal-webpack-plugin/-/clean-terminal-webpack-plugin-3.0.0.tgz",
"integrity": "sha512-wcgkQZmwEWYYjHblXc0+UGFDtx37S+1qgUQl4EOhhinzSHbZpixWBiasQ91RoCMf5lAm67j1XOt9z+HN+sWkWA==",
"dev": true,
"requires": {}
},
"cli-boxes": {
"version": "2.2.1",
"resolved": "https://registry.npmjs.org/cli-boxes/-/cli-boxes-2.2.1.tgz",

View file

@ -27,7 +27,6 @@
"@types/tinycolor2": "1.4.3",
"buffer": "6.0.3",
"circular-dependency-plugin": "5.2.2",
"clean-terminal-webpack-plugin": "3.0.0",
"copy-webpack-plugin": "10.2.4",
"css-loader": "6.7.1",
"css-minimizer-webpack-plugin": "3.4.1",

View file

@ -3,7 +3,6 @@ const CopyPlugin = require("copy-webpack-plugin");
const CircularDependencyPlugin = require("circular-dependency-plugin");
const MiniCssExtractPlugin = require("mini-css-extract-plugin");
const HtmlWebpackPlugin = require("html-webpack-plugin");
const CleanTerminalPlugin = require("clean-terminal-webpack-plugin");
let circularImports = 0;
@ -73,7 +72,6 @@ const BASE_CONFIG = {
},
},
plugins: [
new CleanTerminalPlugin(),
new CircularDependencyPlugin({
exclude: /node_modules/,
include: /./,