Skip to content
This repository was archived by the owner on Dec 11, 2019. It is now read-only.

Commit b511d2e

Browse files
committed
Merge pull request #15003 from NejcZdovc/captcha2
Use v2 promotion endpoints
1 parent 45a4f0e commit b511d2e

File tree

10 files changed

+4173
-4150
lines changed

10 files changed

+4173
-4150
lines changed

app/browser/api/ledger.js

Lines changed: 6 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -2944,11 +2944,13 @@ const getCaptcha = (state) => {
29442944
return
29452945
}
29462946

2947-
appActions.onCaptchaResponse(null, body)
2947+
if (response && response.headers && response.headers['captcha-hint']) {
2948+
appActions.onCaptchaResponse(null, body, response.headers['captcha-hint'])
2949+
}
29482950
})
29492951
}
29502952

2951-
const onCaptchaResponse = (state, response, body) => {
2953+
const onCaptchaResponse = (state, response, body, hint) => {
29522954
if (body == null) {
29532955
if (response && response.get('statusCode') === 429) {
29542956
return ledgerState.setPromotionProp(state, 'promotionStatus', promotionStatuses.CAPTCHA_BLOCK)
@@ -2966,6 +2968,8 @@ const onCaptchaResponse = (state, response, body) => {
29662968
state = ledgerState.setPromotionProp(state, 'promotionStatus', promotionStatuses.CAPTCHA_CHECK)
29672969
}
29682970

2971+
state = ledgerState.setPromotionProp(state, 'captchaHint', hint || '')
2972+
29692973
return state
29702974
}
29712975

app/browser/reducers/ledgerReducer.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -433,7 +433,7 @@ const ledgerReducer = (state, action, immutableAction) => {
433433
}
434434
case appConstants.APP_ON_CAPTCHA_RESPONSE:
435435
{
436-
state = ledgerApi.onCaptchaResponse(state, action.get('response'), action.get('body'))
436+
state = ledgerApi.onCaptchaResponse(state, action.get('response'), action.get('body'), action.get('hint'))
437437
break
438438
}
439439
case appConstants.APP_ON_CAPTCHA_CLOSE:

app/common/state/ledgerState.js

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -559,6 +559,7 @@ const ledgerState = {
559559
const claim = state.getIn(['ledger', 'promotion', 'claimedTimestamp']) || null
560560
const status = state.getIn(['ledger', 'promotion', 'promotionStatus']) || null
561561
const captcha = state.getIn(['ledger', 'promotion', 'captcha']) || null
562+
const captchaHint = state.getIn(['ledger', 'promotion', 'captchaHint']) || null
562563

563564
if (claim) {
564565
promotion = promotion.set('claimedTimestamp', claim)
@@ -572,6 +573,10 @@ const ledgerState = {
572573
promotion = promotion.set('captcha', captcha)
573574
}
574575

576+
if (captchaHint) {
577+
promotion = promotion.set('captchaHint', captchaHint)
578+
}
579+
575580
return promotion
576581
},
577582

app/extensions/brave/locales/en-US/preferences.properties

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -269,7 +269,7 @@ promotionCaptchaTitle=Almost there!
269269
promotionCaptchaErrorTitle=Hmmm…not quite.
270270
promotionCaptchaErrorText=Please try again.
271271
promotionCaptchaText=First, prove you are human:
272-
promotionCaptchaMessage=Drag and drop the BAT logo onto the target
272+
promotionCaptchaMessageNew=Drag and drop the BAT logo onto the <b>{{hint}}</b> target
273273
promotionGeneralErrorMessage=The Brave Payments server is not responding. Please try again later to claim your token grant.
274274
promotionGeneralErrorText=Note: This error could also be caused by a network connection problem.
275275
promotionGeneralErrorTitle=Uh oh.

app/renderer/components/preferences/payment/captcha.js

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -112,7 +112,12 @@ class Captcha extends ImmutableComponent {
112112
<img src={arrowIcon} draggable='false' className={css(styles.enabledContent__captcha__arrow, styles.disableDND)} />
113113
</div>
114114
<div draggable='false' onDrop={this.onCaptchaDrop} onDragOver={this.preventDefault} className={css(styles.enabledContent__captcha__drop, styles.disableDND)} />
115-
<p draggable='false' className={css(styles.enabledContent__overlay_text, styles.disableDND)} data-l10n-id='promotionCaptchaMessage' />
115+
<p
116+
draggable='false'
117+
className={css(styles.enabledContent__overlay_text, styles.disableDND)}
118+
data-l10n-id='promotionCaptchaMessageNew'
119+
data-l10n-args={JSON.stringify({hint: this.props.promo.get('captchaHint')})}
120+
/>
116121
</div>
117122
}
118123
}

docs/state.md

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -262,6 +262,7 @@ AppStore
262262
},
263263
promotion: {
264264
activeState: string,
265+
captchaHint: string,
265266
claimedTimestamp: number,
266267
minimumReconcileTimestamp: number,
267268
promotionId: number,

js/actions/appActions.js

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1877,11 +1877,12 @@ const appActions = {
18771877
})
18781878
},
18791879

1880-
onCaptchaResponse: function (response, body) {
1880+
onCaptchaResponse: function (response, body, hint) {
18811881
dispatch({
18821882
actionType: appConstants.APP_ON_CAPTCHA_RESPONSE,
18831883
body,
1884-
response
1884+
response,
1885+
hint
18851886
})
18861887
},
18871888

0 commit comments

Comments
 (0)