fix: add backwards compatibility code
This commit is contained in:
parent
2788962ac7
commit
cb6df3f86c
2 changed files with 13 additions and 6 deletions
|
|
@ -118,25 +118,32 @@ const getGlobalNotifications = config => getNotifications(null, null, config)
|
|||
const getTriggers = _.get('triggers')
|
||||
|
||||
/* `customInfoRequests` is the result of a call to `getCustomInfoRequests` */
|
||||
const getTriggersAutomation = (customInfoRequests, config) => {
|
||||
const getTriggersAutomation = (customInfoRequests, config, oldFormat = false) => {
|
||||
return customInfoRequests
|
||||
.then(infoRequests => {
|
||||
const defaultAutomation = _.get('triggersConfig_automation')(config)
|
||||
const overrides = _.get('triggersConfig_overrides')(config)
|
||||
|
||||
const requirements = {
|
||||
sanctions: defaultAutomation,
|
||||
idCardPhoto: defaultAutomation,
|
||||
idCardData: defaultAutomation,
|
||||
facephoto: defaultAutomation,
|
||||
usSsn: defaultAutomation,
|
||||
custom: []
|
||||
usSsn: defaultAutomation
|
||||
}
|
||||
|
||||
if (oldFormat) {
|
||||
_.forEach(it => { requirements[it.id] = defaultAutomation }, infoRequests)
|
||||
const oldRequirementsOverrides = _.reduce((acc, override) => _.assign(acc, { [override.requirement]: override.automation }), {}, overrides)
|
||||
return _.assign(requirements, oldRequirementsOverrides)
|
||||
}
|
||||
|
||||
requirements.custom = []
|
||||
|
||||
_.forEach(it => {
|
||||
requirements.custom.push({ id: it.id, type: defaultAutomation })
|
||||
}, infoRequests)
|
||||
|
||||
const overrides = _.get('triggersConfig_overrides')(config)
|
||||
|
||||
const requirementsOverrides = _.reduce((acc, override) => {
|
||||
return _.assign(
|
||||
acc,
|
||||
|
|
|
|||
|
|
@ -85,7 +85,7 @@ function poll (req, res, next) {
|
|||
pi.recordPing(deviceTime, machineVersion, machineModel),
|
||||
pi.pollQueries(),
|
||||
buildTriggers(configManager.getTriggers(settings.config)),
|
||||
configManager.getTriggersAutomation(getCustomInfoRequests(true), settings.config),
|
||||
configManager.getTriggersAutomation(getCustomInfoRequests(true), settings.config, true),
|
||||
])
|
||||
.then(([_pingRes, results, triggers, triggersAutomation]) => {
|
||||
const reboot = pid && state.reboots?.[operatorId]?.[deviceId] === pid
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue