From dc2a39a19ea1ec4917c5fe12ccfb60d4553f9b53 Mon Sep 17 00:00:00 2001 From: Chris Taylor Date: Fri, 20 Dec 2024 21:36:06 +0000 Subject: [PATCH] Hot fix captcha count when DB records don't contain counts --- packages/provider/src/api/public.ts | 1 - .../src/tasks/imgCaptcha/imgCaptchaTasks.ts | 24 +++++++++++++++---- 2 files changed, 20 insertions(+), 5 deletions(-) diff --git a/packages/provider/src/api/public.ts b/packages/provider/src/api/public.ts index cd89133a0..543a602d7 100644 --- a/packages/provider/src/api/public.ts +++ b/packages/provider/src/api/public.ts @@ -19,7 +19,6 @@ import express, { type Router } from "express"; import { Tasks } from "../tasks/tasks.js"; import { handleErrors } from "./errorHandler.js"; -const NO_IP_ADDRESS = "NO_IP_ADDRESS" as const; const DEFAULT_FRICTIONLESS_THRESHOLD = 0.5; /** diff --git a/packages/provider/src/tasks/imgCaptcha/imgCaptchaTasks.ts b/packages/provider/src/tasks/imgCaptcha/imgCaptchaTasks.ts index 18c12beaf..474778fee 100644 --- a/packages/provider/src/tasks/imgCaptcha/imgCaptchaTasks.ts +++ b/packages/provider/src/tasks/imgCaptcha/imgCaptchaTasks.ts @@ -473,15 +473,31 @@ export class ImgCaptchaManager { const ipRule = await checkIpRules(this.db, ipAddress, dapp); if (ipRule) { return { - solved: { count: ipRule?.captchaConfig?.solved.count || 0 }, - unsolved: { count: ipRule?.captchaConfig?.unsolved.count || 0 }, + solved: { + count: + ipRule?.captchaConfig?.solved.count || + this.config.captchas.solved.count, + }, + unsolved: { + count: + ipRule?.captchaConfig?.unsolved.count || + this.config.captchas.unsolved.count, + }, }; } const userRule = await checkUserRules(this.db, user, dapp); if (userRule) { return { - solved: { count: userRule?.captchaConfig?.solved.count || 0 }, - unsolved: { count: userRule?.captchaConfig?.unsolved.count || 0 }, + solved: { + count: + userRule?.captchaConfig?.solved.count || + this.config.captchas.solved.count, + }, + unsolved: { + count: + userRule?.captchaConfig?.unsolved.count || + this.config.captchas.unsolved.count, + }, }; } return this.config.captchas;