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')
|
const getTriggers = _.get('triggers')
|
||||||
|
|
||||||
/* `customInfoRequests` is the result of a call to `getCustomInfoRequests` */
|
/* `customInfoRequests` is the result of a call to `getCustomInfoRequests` */
|
||||||
const getTriggersAutomation = (customInfoRequests, config) => {
|
const getTriggersAutomation = (customInfoRequests, config, oldFormat = false) => {
|
||||||
return customInfoRequests
|
return customInfoRequests
|
||||||
.then(infoRequests => {
|
.then(infoRequests => {
|
||||||
const defaultAutomation = _.get('triggersConfig_automation')(config)
|
const defaultAutomation = _.get('triggersConfig_automation')(config)
|
||||||
|
const overrides = _.get('triggersConfig_overrides')(config)
|
||||||
|
|
||||||
const requirements = {
|
const requirements = {
|
||||||
sanctions: defaultAutomation,
|
sanctions: defaultAutomation,
|
||||||
idCardPhoto: defaultAutomation,
|
idCardPhoto: defaultAutomation,
|
||||||
idCardData: defaultAutomation,
|
idCardData: defaultAutomation,
|
||||||
facephoto: defaultAutomation,
|
facephoto: defaultAutomation,
|
||||||
usSsn: defaultAutomation,
|
usSsn: defaultAutomation
|
||||||
custom: []
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
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 => {
|
_.forEach(it => {
|
||||||
requirements.custom.push({ id: it.id, type: defaultAutomation })
|
requirements.custom.push({ id: it.id, type: defaultAutomation })
|
||||||
}, infoRequests)
|
}, infoRequests)
|
||||||
|
|
||||||
const overrides = _.get('triggersConfig_overrides')(config)
|
|
||||||
|
|
||||||
const requirementsOverrides = _.reduce((acc, override) => {
|
const requirementsOverrides = _.reduce((acc, override) => {
|
||||||
return _.assign(
|
return _.assign(
|
||||||
acc,
|
acc,
|
||||||
|
|
|
||||||
|
|
@ -85,7 +85,7 @@ function poll (req, res, next) {
|
||||||
pi.recordPing(deviceTime, machineVersion, machineModel),
|
pi.recordPing(deviceTime, machineVersion, machineModel),
|
||||||
pi.pollQueries(),
|
pi.pollQueries(),
|
||||||
buildTriggers(configManager.getTriggers(settings.config)),
|
buildTriggers(configManager.getTriggers(settings.config)),
|
||||||
configManager.getTriggersAutomation(getCustomInfoRequests(true), settings.config),
|
configManager.getTriggersAutomation(getCustomInfoRequests(true), settings.config, true),
|
||||||
])
|
])
|
||||||
.then(([_pingRes, results, triggers, triggersAutomation]) => {
|
.then(([_pingRes, results, triggers, triggersAutomation]) => {
|
||||||
const reboot = pid && state.reboots?.[operatorId]?.[deviceId] === pid
|
const reboot = pid && state.reboots?.[operatorId]?.[deviceId] === pid
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue