mirror of
https://github.com/jambonz/jambonz-feature-server.git
synced 2025-12-21 17:17:58 +00:00
add customizer for merging arrays
This commit is contained in:
@@ -1,4 +1,6 @@
|
||||
const obj = require('drachtio-fsmrf/lib/utils');
|
||||
const Emitter = require('events');
|
||||
const { isArray } = require('lodash');
|
||||
const lodash = require('lodash');
|
||||
const hasKeys = (obj) => typeof obj === 'object' && Object.keys(obj) > 0;
|
||||
|
||||
@@ -18,11 +20,17 @@ class SpeechConfig extends Emitter {
|
||||
|
||||
_mergeConfig(changedConfig = {}) {
|
||||
const merged = lodash.merge(
|
||||
{},
|
||||
this.sessionConfig,
|
||||
changedConfig
|
||||
changedConfig,
|
||||
(objValue, sourceValue) => {
|
||||
if(isArray(objValue)){
|
||||
if(isArray(sourceValue)){
|
||||
return sourceValue;
|
||||
}
|
||||
return objValue;
|
||||
}
|
||||
}
|
||||
);
|
||||
merged.bargein.enable = changedConfig.bargein?.enable?.length === 0 ? [] : changedConfig.bargein?.enable;
|
||||
this.logger.debug({merged, sessionConfig: this.sessionConfig, changedConfig}, 'merged config');
|
||||
// should we override hints with empty array or leave it as it is once saved?
|
||||
// merged.recognizer.hints = changedConfig.recognizer?.hints
|
||||
|
||||
Reference in New Issue
Block a user