i need remove ctx stranger

This commit is contained in:
Leifer Mendez
2022-11-19 21:07:41 +01:00
parent 7cf013e52b
commit 4879df040f
8 changed files with 140 additions and 51 deletions

View File

@@ -47,7 +47,8 @@ class CoreClass {
* @private
* @param {*} ctxMessage
*/
handleMsg = async ({ body, from }) => {
handleMsg = async (messageInComming) => {
const { body, from } = messageInComming
let msgToSend = []
const prevMsg = await this.databaseClass.getPrevByNumber(from)
@@ -64,6 +65,17 @@ class CoreClass {
const refToContinue = this.flowClass.findBySerialize(
prevMsg.refSerialize
)
if (refToContinue && prevMsg?.options?.callback) {
const indexFlow = this.flowClass.findIndexByRef(
refToContinue?.ref
)
this.flowClass.allCallbacks[indexFlow].callback(
messageInComming
)
}
msgToSend = this.flowClass.find(refToContinue?.ref, true) || []
} else {
msgToSend = this.flowClass.find(body) || []