Feat: user compliance saving to DB
This commit is contained in:
parent
204e421b3d
commit
2a9e8dadba
7 changed files with 79 additions and 29 deletions
|
|
@ -28,6 +28,7 @@ const compliance = require('./compliance')
|
|||
const promoCodes = require('./promo-codes')
|
||||
const BN = require('./bn')
|
||||
const commissionMath = require('./commission-math')
|
||||
const notifier = require('./notifier/index')
|
||||
|
||||
const version = require('../package.json').version
|
||||
|
||||
|
|
@ -108,7 +109,6 @@ function poll (req, res, next) {
|
|||
operatorInfo,
|
||||
triggers
|
||||
}
|
||||
|
||||
// BACKWARDS_COMPATIBILITY 7.5
|
||||
// machines before 7.5 expect old compliance
|
||||
if (!machineVersion || semver.lt(machineVersion, '7.5.0-beta.0')) {
|
||||
|
|
@ -324,6 +324,7 @@ function updateCustomer (req, res, next) {
|
|||
}
|
||||
|
||||
function triggerSanctions (req, res, next) {
|
||||
console.log("SANCTIONS TRIGGERED")
|
||||
const id = req.params.id
|
||||
|
||||
customers.getById(id)
|
||||
|
|
@ -342,7 +343,10 @@ function triggerBlock (req, res, next) {
|
|||
const id = req.params.id
|
||||
|
||||
customers.update(id, { authorizedOverride: 'blocked' })
|
||||
.then(customer => respond(req, res, { customer }))
|
||||
.then(customer => {
|
||||
notifier.customerComplianceNotify(customer, req.deviceId, 'BLOCKED')
|
||||
return respond(req, res, { customer })
|
||||
})
|
||||
.catch(next)
|
||||
}
|
||||
|
||||
|
|
@ -358,7 +362,10 @@ function triggerSuspend (req, res, next) {
|
|||
const date = new Date()
|
||||
date.setDate(date.getDate() + days);
|
||||
customers.update(id, { suspendedUntil: date })
|
||||
.then(customer => respond(req, res, { customer }))
|
||||
.then(customer => {
|
||||
notifier.customerComplianceNotify(customer, req.deviceId, 'SUSPENDED', days)
|
||||
respond(req, res, { customer })
|
||||
})
|
||||
.catch(next)
|
||||
}
|
||||
|
||||
|
|
@ -423,7 +430,6 @@ function errorHandler (err, req, res, next) {
|
|||
function respond (req, res, _body, _status) {
|
||||
const status = _status || 200
|
||||
const body = _body || {}
|
||||
|
||||
return res.status(status).json(body)
|
||||
}
|
||||
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue