refactor: give settings object to complianceNotify
This commit is contained in:
parent
08843ec73a
commit
068f68e838
2 changed files with 7 additions and 8 deletions
|
|
@ -166,12 +166,9 @@ function transactionNotify (tx, rec) {
|
||||||
})
|
})
|
||||||
}
|
}
|
||||||
|
|
||||||
function complianceNotify (customer, deviceId, action, period) {
|
function complianceNotify (settings, customer, deviceId, action, period) {
|
||||||
return Promise.all([
|
return queries.getMachineName(deviceId)
|
||||||
settingsLoader.loadLatest(),
|
.then(machineName => {
|
||||||
queries.getMachineName(deviceId)
|
|
||||||
])
|
|
||||||
.then(([settings, machineName]) => {
|
|
||||||
const notifications = configManager.getGlobalNotifications(settings.config)
|
const notifications = configManager.getGlobalNotifications(settings.config)
|
||||||
|
|
||||||
const msgCore = {
|
const msgCore = {
|
||||||
|
|
|
||||||
|
|
@ -101,10 +101,11 @@ function triggerSanctions (req, res, next) {
|
||||||
|
|
||||||
function triggerBlock (req, res, next) {
|
function triggerBlock (req, res, next) {
|
||||||
const id = req.params.id
|
const id = req.params.id
|
||||||
|
const settings = req.settings
|
||||||
|
|
||||||
customers.update(id, { authorizedOverride: 'blocked' })
|
customers.update(id, { authorizedOverride: 'blocked' })
|
||||||
.then(customer => {
|
.then(customer => {
|
||||||
notifier.complianceNotify(customer, req.deviceId, 'BLOCKED')
|
notifier.complianceNotify(settings, customer, req.deviceId, 'BLOCKED')
|
||||||
return respond(req, res, { customer })
|
return respond(req, res, { customer })
|
||||||
})
|
})
|
||||||
.catch(next)
|
.catch(next)
|
||||||
|
|
@ -113,6 +114,7 @@ function triggerBlock (req, res, next) {
|
||||||
function triggerSuspend (req, res, next) {
|
function triggerSuspend (req, res, next) {
|
||||||
const id = req.params.id
|
const id = req.params.id
|
||||||
const triggerId = req.body.triggerId
|
const triggerId = req.body.triggerId
|
||||||
|
const settings = req.settings
|
||||||
|
|
||||||
const triggers = configManager.getTriggers(req.settings.config)
|
const triggers = configManager.getTriggers(req.settings.config)
|
||||||
const getSuspendDays = _.compose(_.get('suspensionDays'), _.find(_.matches({ id: triggerId })))
|
const getSuspendDays = _.compose(_.get('suspensionDays'), _.find(_.matches({ id: triggerId })))
|
||||||
|
|
@ -123,7 +125,7 @@ function triggerSuspend (req, res, next) {
|
||||||
|
|
||||||
customers.update(id, { suspendedUntil: add(suspensionDuration, new Date()) })
|
customers.update(id, { suspendedUntil: add(suspensionDuration, new Date()) })
|
||||||
.then(customer => {
|
.then(customer => {
|
||||||
notifier.complianceNotify(customer, req.deviceId, 'SUSPENDED', days)
|
notifier.complianceNotify(settings, customer, req.deviceId, 'SUSPENDED', days)
|
||||||
return respond(req, res, { customer })
|
return respond(req, res, { customer })
|
||||||
})
|
})
|
||||||
.catch(next)
|
.catch(next)
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue