diff --git a/packages/apps/human-app/server/src/modules/h-captcha/h-captcha.service.ts b/packages/apps/human-app/server/src/modules/h-captcha/h-captcha.service.ts index bd634dae58..09174073eb 100644 --- a/packages/apps/human-app/server/src/modules/h-captcha/h-captcha.service.ts +++ b/packages/apps/human-app/server/src/modules/h-captcha/h-captcha.service.ts @@ -24,7 +24,9 @@ import { HCaptchaVerifyGateway } from '../../integrations/h-captcha-labeling/h-c export class HCaptchaService { BAD_REQUEST = 400; OK = 200; - DAILY_HMT_SPENT_CACHE_KEY = 'daily-hmt-spent-cache'; + get dailyHmtSpentCacheKey() { + return 'daily-hmt-spent-cache'; + } private readonly logger = new Logger(HCaptchaService.name); constructor( private configService: EnvironmentConfigService, @@ -72,12 +74,12 @@ export class HCaptchaService { ): Promise { this.checkIfHcaptchaSitekeyPresent(command.siteKey); let dailyHmtSpent = await this.cacheManager.get( - this.DAILY_HMT_SPENT_CACHE_KEY, + this.dailyHmtSpentCacheKey ); if (!dailyHmtSpent) { dailyHmtSpent = await this.hCaptchaLabelingGateway.fetchDailyHmtSpent(); await this.cacheManager.set( - this.DAILY_HMT_SPENT_CACHE_KEY, + this.dailyHmtSpentCacheKey, dailyHmtSpent, this.configService.cacheTtlDailyHmtSpent, ); diff --git a/packages/apps/human-app/server/src/modules/h-captcha/spec/h-captcha.service.spec.ts b/packages/apps/human-app/server/src/modules/h-captcha/spec/h-captcha.service.spec.ts index a39babac1d..b85c197c18 100644 --- a/packages/apps/human-app/server/src/modules/h-captcha/spec/h-captcha.service.spec.ts +++ b/packages/apps/human-app/server/src/modules/h-captcha/spec/h-captcha.service.spec.ts @@ -193,6 +193,7 @@ describe('HCaptchaService', () => { const result = await service.getDailyHmtSpent(command); expect(result).toEqual(dailyHmtSpentResponseFixture); expect(cacheManager.set).toHaveBeenCalledWith( + service.dailyHmtSpentCacheKey, dailyHmtSpentResponseFixture, configService.cacheTtlDailyHmtSpent, );