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

@ -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)