feat: suspension trigger
This commit is contained in:
parent
118852a433
commit
e0581fc39b
4 changed files with 31 additions and 6 deletions
|
|
@ -215,6 +215,7 @@ function addOrUpdateCustomer (req) {
|
|||
const machineVersion = req.query.version
|
||||
const triggers = configManager.getTriggers(req.settings.config)
|
||||
const compatTriggers = complianceTriggers.getBackwardsCompatibleTriggers(triggers)
|
||||
const maxDaysThreshold = complianceTriggers.maxDaysThreshold(triggers)
|
||||
|
||||
return customers.get(customerData.phone)
|
||||
.then(customer => {
|
||||
|
|
@ -235,8 +236,7 @@ function addOrUpdateCustomer (req) {
|
|||
return customers.update(customer.id, patch)
|
||||
})
|
||||
}).then(customer => {
|
||||
// TODO new-admin: only get customer history till max needed for triggers
|
||||
return Tx.customerHistory(customer.id)
|
||||
return Tx.customerHistory(customer.id, maxDaysThreshold)
|
||||
.then(result => {
|
||||
customer.txHistory = result
|
||||
return customer
|
||||
|
|
@ -318,7 +318,12 @@ function triggerBlock (req, res, next) {
|
|||
function triggerSuspend (req, res, next) {
|
||||
const id = req.params.id
|
||||
|
||||
customers.update(id, { authorizedOverride: 'blocked' })
|
||||
const triggers = configManager.getTriggers(req.settings.config)
|
||||
const trigger = _.find(_.matches({ id: req.body.triggerId }))(triggers)
|
||||
|
||||
const date = new Date()
|
||||
date.setDate(date.getDate() + trigger.suspensionDays);
|
||||
customers.update(id, { suspendedUntil: date })
|
||||
.then(customer => respond(req, res, { customer }))
|
||||
.catch(next)
|
||||
}
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue