sending to inbox if user got banned

This commit is contained in:
Miodec 2022-09-04 20:03:27 +02:00
parent 002d007f1f
commit 18f9785e04

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");