From a32f873808016edb00f95aca0b4f30ff53f68fc2 Mon Sep 17 00:00:00 2001 From: Michael McLaughlin Date: Thu, 4 Apr 2019 17:06:19 -0500 Subject: [PATCH] reworked cooldown bypass logic --- ledger/controllers/grants.js | 11 ++++------- 1 file changed, 4 insertions(+), 7 deletions(-) diff --git a/ledger/controllers/grants.js b/ledger/controllers/grants.js index 3606c65d0..f7721fe4c 100644 --- a/ledger/controllers/grants.js +++ b/ledger/controllers/grants.js @@ -283,7 +283,7 @@ const getGrant = (protocolVersion) => (runtime) => { wallet.grants.forEach((grant) => { promotionIds.push(grant.promotionId) }) } underscore.extend(query, { promotionId: { $nin: promotionIds } }) - walletTooYoung = walletCooldown(runtime, wallet, bypassCooldown) + walletTooYoung = walletCooldown(wallet, bypassCooldown) } if (protocolVersion === 4 && !paymentId) { @@ -1171,16 +1171,13 @@ function uploadTypedGrants (protocolVersion, uploadSchema, contentSchema) { } } -function walletCooldown (runtime, wallet, bypassCooldown) { - const { paymentId, _id } = wallet +function walletCooldown (wallet, bypassCooldown) { + const { _id } = wallet const { WALLET_COOLDOWN_BYPASS_TOKEN } = process.env - if (bypassCooldown !== WALLET_COOLDOWN_BYPASS_TOKEN) { + if (isProduction || bypassCooldown !== WALLET_COOLDOWN_BYPASS_TOKEN) { const offset = cooldownOffset() const createdTime = braveUtils.createdTimestamp(_id) return createdTime > (new Date() - offset) - } else if (WALLET_COOLDOWN_BYPASS_TOKEN && isProduction) { - // report to sentry that a bypass is being used - runtime.captureException(new Error('wallet bypass used'), { paymentId }) } return false }