Chore: merge compliance notification code changes
This commit is contained in:
parent
fc39d9b1a3
commit
757db75d1a
7 changed files with 36 additions and 21 deletions
|
|
@ -8,6 +8,8 @@ const complianceTriggers = require('../compliance-triggers')
|
|||
const configManager = require('../new-config-manager')
|
||||
const customers = require('../customers')
|
||||
const httpError = require('../route-helpers').httpError
|
||||
const notifier = require('../notifier')
|
||||
const respond = require('../respond')
|
||||
|
||||
function updateCustomer (req, res, next) {
|
||||
const id = req.params.id
|
||||
|
|
@ -37,7 +39,7 @@ function updateCustomer (req, res, next) {
|
|||
.then(newPatch => customers.updateFrontCamera(id, newPatch))
|
||||
.then(newPatch => customers.update(id, newPatch, null, txId))
|
||||
})
|
||||
.then(customer => res.status(200).json({ customer }))
|
||||
.then(customer => respond(req, res, { customer }))
|
||||
.catch(next)
|
||||
}
|
||||
|
||||
|
|
@ -50,7 +52,7 @@ function triggerSanctions (req, res, next) {
|
|||
return compliance.validationPatch(req.deviceId, true, customer)
|
||||
.then(patch => customers.update(id, patch))
|
||||
})
|
||||
.then(customer => res.status(200).json({ customer }))
|
||||
.then(customer => respond(req, res, { customer }))
|
||||
.catch(next)
|
||||
}
|
||||
|
||||
|
|
@ -58,7 +60,10 @@ function triggerBlock (req, res, next) {
|
|||
const id = req.params.id
|
||||
|
||||
customers.update(id, { authorizedOverride: 'blocked' })
|
||||
.then(customer => res.status(200).json({ customer }))
|
||||
.then(customer => {
|
||||
notifier.notifyIfActive('compliance', 'customerComplianceNotify', customer, req.deviceId, 'BLOCKED')
|
||||
return respond(req, res, { customer })
|
||||
})
|
||||
.catch(next)
|
||||
}
|
||||
|
||||
|
|
@ -74,7 +79,10 @@ function triggerSuspend (req, res, next) {
|
|||
const date = new Date()
|
||||
date.setDate(date.getDate() + days)
|
||||
customers.update(id, { suspendedUntil: date })
|
||||
.then(customer => res.status(200).json({ customer }))
|
||||
.then(customer => {
|
||||
notifier.notifyIfActive('compliance', 'customerComplianceNotify', customer, req.deviceId, 'SUSPENDED', days)
|
||||
return respond(req, res, { customer })
|
||||
})
|
||||
.catch(next)
|
||||
}
|
||||
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue