mirror of
https://github.com/cheveguerra/bot-whatsapp.git
synced 2026-04-18 03:29:15 +00:00
fix(bot): ⚡ working callback Phase 1
This commit is contained in:
@@ -1,3 +1,4 @@
|
||||
const { flatObject } = require('../../utils/flattener')
|
||||
const { generateRef } = require('../../utils/hash')
|
||||
const { toJson } = require('./toJson')
|
||||
/**
|
||||
@@ -35,24 +36,7 @@ const addAnswer =
|
||||
* Esta funcion aplana y busca los callback anidados de los hijos
|
||||
* @returns
|
||||
*/
|
||||
const getCbFromNested = () => {
|
||||
const cbNestedList = Array.isArray(nested) ? nested : []
|
||||
const cbNestedObj = cbNestedList.map(({ ctx }) => ctx?.callbacks)
|
||||
const queueCb = cbNestedObj.reduce((acc, current) => {
|
||||
const getKeys = Object.keys(current)
|
||||
const parse = getKeys.map((icb, i) => ({
|
||||
[icb]: Object.values(current)[i],
|
||||
}))
|
||||
return [...acc, ...parse]
|
||||
}, [])
|
||||
|
||||
const flatObj = {}
|
||||
for (const iteration of queueCb) {
|
||||
const [keyCb] = Object.keys(iteration)
|
||||
flatObj[keyCb] = iteration[keyCb]
|
||||
}
|
||||
return flatObj
|
||||
}
|
||||
const getCbFromNested = () => flatObject(nested)
|
||||
|
||||
const callback = typeof cb === 'function' ? cb : () => null
|
||||
|
||||
|
||||
Reference in New Issue
Block a user