Skip to content

Commit

Permalink
Hot fix captcha count when DB records don't contain counts (#1582)
Browse files Browse the repository at this point in the history
  • Loading branch information
forgetso authored Dec 20, 2024
2 parents 4fbbdb4 + dc2a39a commit 9f12acf
Show file tree
Hide file tree
Showing 2 changed files with 20 additions and 5 deletions.
1 change: 0 additions & 1 deletion packages/provider/src/api/public.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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;

/**
Expand Down
24 changes: 20 additions & 4 deletions packages/provider/src/tasks/imgCaptcha/imgCaptchaTasks.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand Down

0 comments on commit 9f12acf

Please sign in to comment.