feat: add operatorId to l-a-s middlewares
fix: make changes to db event handler to receive more complex payloads feat: machine actions previously on REST now work based on notifications feat: state middleware now operates based on operatorId as well chore: remove old localAppRoutes related code
This commit is contained in:
parent
32e5b1ba87
commit
7135a03654
11 changed files with 71 additions and 78 deletions
|
|
@ -8,6 +8,7 @@ const { getCashInSettings } = require('../new-config-manager')
|
|||
const { AUTOMATIC } = require('../constants.js')
|
||||
|
||||
function notifyCashboxRemoval (req, res, next) {
|
||||
const operatorId = res.locals.operatorId
|
||||
return Promise.all([getMachine(req.deviceId), loadLatestConfig()])
|
||||
.then(([machine, config]) => {
|
||||
const cashInSettings = getCashInSettings(config)
|
||||
|
|
@ -15,7 +16,7 @@ function notifyCashboxRemoval (req, res, next) {
|
|||
return res.status(200).send({ status: 'OK' })
|
||||
}
|
||||
return cashbox.createCashboxBatch(req.deviceId, machine.cashbox)
|
||||
.then(() => setMachine({ deviceId: req.deviceId, action: 'emptyCashInBills' }))
|
||||
.then(() => setMachine({ deviceId: req.deviceId, action: 'emptyCashInBills' }, operatorId))
|
||||
.then(() => res.status(200).send({ status: 'OK' }))
|
||||
})
|
||||
.catch(next)
|
||||
|
|
|
|||
|
|
@ -1,48 +0,0 @@
|
|||
const express = require('express')
|
||||
const router = express.Router()
|
||||
|
||||
const state = require('../middlewares/state')
|
||||
|
||||
router.get('/pid', (req, res) => {
|
||||
const deviceId = req.query.device_id
|
||||
const pidRec = state.pids[deviceId]
|
||||
res.json(pidRec)
|
||||
})
|
||||
|
||||
router.post('/reboot', (req, res) => {
|
||||
const deviceId = req.query.device_id
|
||||
const pid = state.pids[deviceId] && state.pids[deviceId].pid
|
||||
|
||||
if (!deviceId || !pid) {
|
||||
return res.sendStatus(400)
|
||||
}
|
||||
|
||||
state.reboots[deviceId] = pid
|
||||
res.sendStatus(200)
|
||||
})
|
||||
|
||||
router.post('/shutdown', (req, res) => {
|
||||
const deviceId = req.query.device_id
|
||||
const pid = state.pids[deviceId] && state.pids[deviceId].pid
|
||||
|
||||
if (!deviceId || !pid) {
|
||||
return res.sendStatus(400)
|
||||
}
|
||||
|
||||
state.shutdowns[deviceId] = pid
|
||||
res.sendStatus(200)
|
||||
})
|
||||
|
||||
router.post('/restartServices', (req, res) => {
|
||||
const deviceId = req.query.device_id
|
||||
const pid = state.pids[deviceId] && state.pids[deviceId].pid
|
||||
|
||||
if (!deviceId || !pid) {
|
||||
return res.sendStatus(400)
|
||||
}
|
||||
|
||||
state.restartServicesMap[deviceId] = pid
|
||||
res.sendStatus(200)
|
||||
})
|
||||
|
||||
module.exports = router
|
||||
|
|
@ -31,6 +31,7 @@ function poll (req, res, next) {
|
|||
const serialNumber = req.query.sn
|
||||
const pid = req.query.pid
|
||||
const settings = req.settings
|
||||
const operatorId = res.locals.operatorId
|
||||
const localeConfig = configManager.getLocale(deviceId, settings.config)
|
||||
const zeroConfLimits = _.reduce((acc, cryptoCode) => {
|
||||
acc[cryptoCode] = configManager.getWalletSettings(cryptoCode, settings.config).zeroConfLimit
|
||||
|
|
@ -48,15 +49,15 @@ function poll (req, res, next) {
|
|||
const receipt = configManager.getReceipt(settings.config)
|
||||
const terms = configManager.getTermsConditions(settings.config)
|
||||
|
||||
state.pids[deviceId] = { pid, ts: Date.now() }
|
||||
state.pids[operatorId] = { [deviceId]: { pid, ts: Date.now() } }
|
||||
|
||||
return pi.pollQueries(serialNumber, deviceTime, req.query, machineVersion, machineModel)
|
||||
.then(results => {
|
||||
const cassettes = results.cassettes
|
||||
|
||||
const reboot = pid && state.reboots[deviceId] && state.reboots[deviceId] === pid
|
||||
const shutdown = pid && state.shutdowns[deviceId] && state.shutdowns[deviceId] === pid
|
||||
const restartServices = pid && state.restartServicesMap[deviceId] && state.restartServicesMap[deviceId] === pid
|
||||
const reboot = pid && state.reboots?.[operatorId]?.[deviceId] === pid
|
||||
const shutdown = pid && state.shutdowns?.[operatorId]?.[deviceId] === pid
|
||||
const restartServices = pid && state.restartServicesMap?.[operatorId]?.[deviceId] === pid
|
||||
const langs = localeConfig.languages
|
||||
|
||||
const locale = {
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue