feat: only refetch t&c on config change

This commit is contained in:
Taranto 2020-01-22 18:13:01 +00:00 committed by Josh Harvey
parent 9ccdd7d6f9
commit f1edea4e8a
4 changed files with 19 additions and 31 deletions

View file

@ -793,7 +793,8 @@ function plugins (settings, deviceId) {
buy,
sell,
notificationsEnabled,
notifyOperator
notifyOperator,
fetchCurrentConfigVersion
}
}

View file

@ -73,8 +73,6 @@ function poll (req, res, next) {
}
}
const terms = config.termsScreenActive && config.termsScreenText ? createTerms(config) : null
const response = {
error: null,
locale,
@ -95,7 +93,6 @@ function poll (req, res, next) {
frontCameraVerificationActive: config.frontCameraVerificationActive,
frontCameraVerificationThreshold: config.frontCameraVerificationThreshold,
receiptPrintingActive: config.receiptPrintingActive,
terms,
cassettes,
twoWayMode: config.cashOutEnabled,
zeroConfLimit: config.zeroConfLimit,
@ -121,6 +118,21 @@ function poll (req, res, next) {
.catch(next)
}
function getTermsConditions (req, res, next) {
const deviceId = req.deviceId
const settings = req.settings
const config = configManager.unscoped(req.settings.config)
const pi = plugins(settings, deviceId)
const terms = config.termsScreenActive && config.termsScreenText ? createTerms(config) : null
return pi.fetchCurrentConfigVersion().then(version => {
return res.json({ terms, version })
})
.catch(next)
}
function getTx (req, res, next) {
if (req.query.status) {
return helpers.fetchStatusTx(req.params.id, req.query.status)
@ -357,6 +369,7 @@ const skip = (req, res) => _.includes(req.path, ['/poll', '/state', '/logs']) &&
const configRequiredRoutes = [
'/poll',
'/terms_conditions',
'/event',
'/phone_code',
'/customer',
@ -381,6 +394,7 @@ app.use(configRequiredRoutes, populateSettings)
app.use(filterOldRequests)
app.get('/poll', poll)
app.get('/terms_conditions', getTermsConditions)
app.post('/state', stateChange)
app.post('/verify_user', verifyUser)

24
package-lock.json generated
View file

@ -5368,14 +5368,6 @@
}
}
},
"express-bandwidth": {
"version": "0.0.1",
"resolved": "https://registry.npmjs.org/express-bandwidth/-/express-bandwidth-0.0.1.tgz",
"integrity": "sha1-kO32A65WCofzNaOmumfpDIZE240=",
"requires": {
"debug": "^2.2.0"
}
},
"express-limiter": {
"version": "1.6.0",
"resolved": "https://registry.npmjs.org/express-limiter/-/express-limiter-1.6.0.tgz",
@ -5389,14 +5381,6 @@
"defaults": "^1.0.3"
}
},
"express-transform": {
"version": "1.0.1",
"resolved": "https://registry.npmjs.org/express-transform/-/express-transform-1.0.1.tgz",
"integrity": "sha1-RS85yBQLozDaHqKm3cWgtPWCmUc=",
"requires": {
"debug": "^2.2.0"
}
},
"express-ws": {
"version": "3.0.0",
"resolved": "https://registry.npmjs.org/express-ws/-/express-ws-3.0.0.tgz",
@ -12395,14 +12379,6 @@
"punycode": "^1.4.1"
}
},
"transfer-rate": {
"version": "2.2.0",
"resolved": "https://registry.npmjs.org/transfer-rate/-/transfer-rate-2.2.0.tgz",
"integrity": "sha512-WWIzi3tGB5WB+WriYDKKaKWDsUjCHko1UFPU6xjruGtb36l20aBVAPI4ZKcR1VUgvKlCNOhpfMBJZ2gWnlYu/w==",
"requires": {
"on-finished": "2.3.0"
}
},
"trim-newlines": {
"version": "1.0.0",
"resolved": "https://registry.npmjs.org/trim-newlines/-/trim-newlines-1.0.0.tgz",

View file

@ -27,10 +27,8 @@
"ethereumjs-util": "^5.2.0",
"ethereumjs-wallet": "^0.6.0",
"express": "^4.15.4",
"express-bandwidth": "0.0.1",
"express-limiter": "^1.6.0",
"express-rate-limit": "^2.9.0",
"express-transform": "^1.0.1",
"express-ws": "^3.0.0",
"futoin-hkdf": "^1.0.2",
"got": "^7.1.0",
@ -63,7 +61,6 @@
"socket.io": "^2.0.3",
"socket.io-client": "^2.0.3",
"talisman": "^0.20.0",
"transfer-rate": "^2.2.0",
"twilio": "^3.6.1",
"uuid": "^3.1.0",
"web3": "^0.20.6",