mirror of
https://github.com/monkeytypegame/monkeytype.git
synced 2025-10-09 15:15:58 +08:00
returning if user got banned
This commit is contained in:
parent
2f21bff1a2
commit
002d007f1f
1 changed files with 6 additions and 2 deletions
|
@ -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(
|
||||
|
|
Loading…
Add table
Reference in a new issue