Skip to content

Commit

Permalink
allow server provided monthly tip default choices (#723)
Browse files Browse the repository at this point in the history
* allow server side to set monthly tip default choices

* patch subtext

* build Dockerfile with npm ci
  • Loading branch information
evq authored and maikelmclauflin committed Sep 20, 2019
1 parent 703d27b commit ed2f69b
Show file tree
Hide file tree
Showing 5 changed files with 11 additions and 7 deletions.
4 changes: 2 additions & 2 deletions Dockerfile
Original file line number Diff line number Diff line change
Expand Up @@ -14,10 +14,10 @@ RUN apt-get update && apt-get install -y postgresql-client
RUN mkdir -p /usr/src/app && mkdir /usr/src/app/bat-utils
WORKDIR /usr/src/app

RUN npm install -g npm@6.1
RUN npm install -g npm@6.11.3

COPY package.json package-lock.json /usr/src/app/
COPY bat-utils/package.json /usr/src/app/bat-utils/
RUN npm install
RUN npm ci
COPY . /usr/src/app
RUN npm run build
3 changes: 2 additions & 1 deletion ledger/controllers/wallet.js
Original file line number Diff line number Diff line change
Expand Up @@ -23,6 +23,7 @@ const braveJoi = utils.extras.joi
const braveUtils = utils.extras.utils

const defaultTipChoices = (process.env.DEFAULT_TIP_CHOICES && process.env.DEFAULT_TIP_CHOICES.split(',')) || [1, 5, 10]
const defaultMonthlyChoices = (process.env.DEFAULT_MONTHLY_CHOICES && process.env.DEFAULT_MONTHLY_CHOICES.split(',')) || [1, 5, 10]

const v1 = {}
const v2 = {}
Expand Down Expand Up @@ -75,7 +76,7 @@ const read = function (runtime, apiVersion) {
result = underscore.extend(result, { addresses: wallet.addresses })
if (runtime.registrars.persona) {
const { payload } = runtime.registrars.persona
underscore.extend(payload, { defaultTipChoices })
underscore.extend(payload, { defaultTipChoices, defaultMonthlyChoices })
result = underscore.extend(result, { parameters: payload || {} })
}

Expand Down
9 changes: 5 additions & 4 deletions package-lock.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

1 change: 1 addition & 0 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -109,6 +109,7 @@
"rsmq": "^0.8.2",
"rsmq-worker": "^0.5.2",
"sdebug": "^0.9.5",
"subtext": "github:brave-intl/subtext#v5",
"tldjs": "2.2.0",
"tweetnacl": "^1.0.0",
"underscore": "1.8.3",
Expand Down
1 change: 1 addition & 0 deletions test/ledger/wallet.integration.test.js
Original file line number Diff line number Diff line change
Expand Up @@ -206,6 +206,7 @@ test('wallet endpoint returns default tip choices', async (t) => {
body
} = await ledgerAgent.get(`/v2/wallet/${paymentId}`).expect(ok)
t.deepEqual(body.parameters.defaultTipChoices, [1, 5, 10])
t.deepEqual(body.parameters.defaultMonthlyChoices, [1, 5, 10])
})

function walletExpectation (day, wallets = 1) {
Expand Down

0 comments on commit ed2f69b

Please sign in to comment.