Skip to content

Commit

Permalink
fix(bot): 馃悰 flowDynamic stranger behaviour
Browse files Browse the repository at this point in the history
  • Loading branch information
leifermendez committed Jan 20, 2023
1 parent 02c0d8a commit f5a7de3
Show file tree
Hide file tree
Showing 2 changed files with 7 additions and 19 deletions.
1 change: 1 addition & 0 deletions .gitignore
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
/node_modules
/packages/repl
/packages/*/starters
/packages/*/node_modules
/packages/*/dist
Expand Down
25 changes: 6 additions & 19 deletions packages/bot/core/core.class.js
Original file line number Diff line number Diff line change
Expand Up @@ -89,14 +89,18 @@ class CoreClass {

// 馃搫 Esta funcion se encarga de enviar un array de mensajes dentro de este ctx
const sendFlow = async (messageToSend, numberOrId) => {
// [1 Paso] esto esta bien!
if (prevMsg?.options?.capture) await cbEveryCtx(prevMsg?.ref)

const queue = []
for (const ctxMessage of messageToSend) {
const delayMs = ctxMessage?.options?.delay || 0
if (delayMs) await delay(delayMs)
QueuePrincipal.enqueue(() =>
Promise.all([
this.sendProviderAndSave(numberOrId, ctxMessage),
resolveCbEveryCtx(ctxMessage),
this.sendProviderAndSave(numberOrId, ctxMessage).then(
() => resolveCbEveryCtx(ctxMessage)
),
])
)
}
Expand Down Expand Up @@ -139,7 +143,6 @@ class CoreClass {

// 馃搫 Se encarga de revisar si el contexto del mensaje tiene callback o fallback
const resolveCbEveryCtx = async (ctxMessage) => {
if (prevMsg?.options?.capture) return cbEveryCtx(prevMsg?.ref)
if (!ctxMessage?.options?.capture)
return await cbEveryCtx(ctxMessage?.ref)
}
Expand All @@ -153,17 +156,6 @@ class CoreClass {
})
}

if (prevMsg?.ref) resolveCbEveryCtx(prevMsg)

// 馃搫 [options: callback]: Si se tiene un callback se ejecuta
//TODO AQUI
// if (!fallBackFlag) {
// if (prevMsg?.options?.capture) cbEveryCtx(prevMsg?.ref)
// for (const ite of this.flowClass.find(body)) {
// if (!ite?.options?.capture) cbEveryCtx(ite?.ref)
// }
// }

// 馃搫馃(tiene return) [options: nested(array)]: Si se tiene flujos hijos los implementa
if (!fallBackFlag && prevMsg?.options?.nested?.length) {
const nestedRef = prevMsg.options.nested
Expand All @@ -173,11 +165,6 @@ class CoreClass {

msgToSend = this.flowClass.find(body, false, flowStandalone) || []

// //TODO AQUI
// for (const ite of msgToSend) {
// cbEveryCtx(ite?.ref)
// }

sendFlow(msgToSend, from)
return
}
Expand Down

0 comments on commit f5a7de3

Please sign in to comment.