chore: deprecate backwards compatibility code
This commit is contained in:
parent
8221701d99
commit
737672c07a
6 changed files with 8 additions and 262 deletions
|
|
@ -1,6 +1,5 @@
|
|||
const express = require('express')
|
||||
const router = express.Router()
|
||||
const semver = require('semver')
|
||||
const _ = require('lodash/fp')
|
||||
const { zonedTimeToUtc, utcToZonedTime } = require('date-fns-tz/fp')
|
||||
const { add, intervalToDuration } = require('date-fns/fp')
|
||||
|
|
@ -79,11 +78,7 @@ const createPendingManualComplianceNotifs = (settings, customer, deviceId) => {
|
|||
|
||||
function updateCustomer (req, res, next) {
|
||||
const id = req.params.id
|
||||
const machineVersion = req.query.version
|
||||
const txId = req.query.txId
|
||||
const patch = req.body
|
||||
const triggers = configManager.getTriggers(req.settings.config)
|
||||
const compatTriggers = complianceTriggers.getBackwardsCompatibleTriggers(triggers)
|
||||
const deviceId = req.deviceId
|
||||
const settings = req.settings
|
||||
|
||||
|
|
@ -96,15 +91,8 @@ function updateCustomer (req, res, next) {
|
|||
.catch(next)
|
||||
}
|
||||
|
||||
// BACKWARDS_COMPATIBILITY 7.5
|
||||
// machines before 7.5 expect customer with sanctions result
|
||||
const isOlderMachineVersion = !machineVersion || semver.lt(machineVersion, '7.5.0-beta.0')
|
||||
customers.getById(id)
|
||||
.then(customer =>
|
||||
!customer ? Promise.reject(httpError('Not Found', 404)) :
|
||||
!isOlderMachineVersion ? {} :
|
||||
compliance.validationPatch(deviceId, !!compatTriggers.sanctions, _.merge(customer, patch))
|
||||
)
|
||||
.then(customer => !customer ? Promise.reject(httpError('Not Found', 404)) : {})
|
||||
.then(_.merge(patch))
|
||||
.then(newPatch => customers.updatePhotoCard(id, newPatch))
|
||||
.then(newPatch => customers.updateFrontCamera(id, newPatch))
|
||||
|
|
@ -135,7 +123,7 @@ function triggerSanctions (req, res, next) {
|
|||
customers.getById(id)
|
||||
.then(customer => {
|
||||
if (!customer) { throw httpError('Not Found', 404) }
|
||||
return compliance.validationPatch(req.deviceId, true, customer)
|
||||
return compliance.validationPatch(req.deviceId, customer)
|
||||
.then(patch => customers.update(id, patch))
|
||||
})
|
||||
.then(customer => respond(req, res, { customer }))
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue