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 a7823736e6
commit 8f28b7aa0a
2 changed files with 19 additions and 4 deletions

View file

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

View file

@ -72,8 +72,6 @@ function poll (req, res, next) {
} }
} }
const terms = config.termsScreenActive && config.termsScreenText ? createTerms(config) : null
const response = { const response = {
error: null, error: null,
locale, locale,
@ -94,7 +92,6 @@ function poll (req, res, next) {
frontCameraVerificationActive: config.frontCameraVerificationActive, frontCameraVerificationActive: config.frontCameraVerificationActive,
frontCameraVerificationThreshold: config.frontCameraVerificationThreshold, frontCameraVerificationThreshold: config.frontCameraVerificationThreshold,
receiptPrintingActive: config.receiptPrintingActive, receiptPrintingActive: config.receiptPrintingActive,
terms,
cassettes, cassettes,
twoWayMode: config.cashOutEnabled, twoWayMode: config.cashOutEnabled,
zeroConfLimit: config.zeroConfLimit, zeroConfLimit: config.zeroConfLimit,
@ -120,6 +117,21 @@ function poll (req, res, next) {
.catch(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) { function getTx (req, res, next) {
if (req.query.status) { if (req.query.status) {
return helpers.fetchStatusTx(req.params.id, req.query.status) return helpers.fetchStatusTx(req.params.id, req.query.status)
@ -356,6 +368,7 @@ const skip = (req, res) => _.includes(req.path, ['/poll', '/state', '/logs']) &&
const configRequiredRoutes = [ const configRequiredRoutes = [
'/poll', '/poll',
'/terms_conditions',
'/event', '/event',
'/phone_code', '/phone_code',
'/customer', '/customer',
@ -379,6 +392,7 @@ app.use(configRequiredRoutes, populateSettings)
app.use(filterOldRequests) app.use(filterOldRequests)
app.get('/poll', poll) app.get('/poll', poll)
app.get('/terms_conditions', getTermsConditions)
app.post('/state', stateChange) app.post('/state', stateChange)
app.post('/verify_user', verifyUser) app.post('/verify_user', verifyUser)