protecting against negative xp

This commit is contained in:
Miodec 2023-01-11 22:03:51 +01:00
parent a15285d044
commit 75d635eef5

View file

@ -412,6 +412,18 @@ export async function addResult(
streak
);
if (xpGained.xp < 0) {
throw new MonkeyError(
500,
"Calculated XP is negative",
JSON.stringify({
xpGained,
result,
}),
uid
);
}
const weeklyXpLeaderboardConfig = req.ctx.configuration.leaderboards.weeklyXp;
let weeklyXpLeaderboardRank = -1;
const eligibleForWeeklyXpLeaderboard =