From 279c4697ddcf97a0f382f0fe5d1c82cec4dbffb9 Mon Sep 17 00:00:00 2001 From: adriano Date: Thu, 7 Mar 2024 19:38:22 -0300 Subject: [PATCH] fix: save contact by remote whatsapp session --- backend/src/helpers/GetDefaultWhatsApp.ts | 8 ++++---- backend/src/services/WbotServices/CheckIsValidContact.ts | 5 +++++ 2 files changed, 9 insertions(+), 4 deletions(-) diff --git a/backend/src/helpers/GetDefaultWhatsApp.ts b/backend/src/helpers/GetDefaultWhatsApp.ts index c19757a..6adc34d 100644 --- a/backend/src/helpers/GetDefaultWhatsApp.ts +++ b/backend/src/helpers/GetDefaultWhatsApp.ts @@ -25,7 +25,7 @@ const GetDefaultWhatsApp = async ({ where: { isDefault: true } }); - if (!defaultWhatsapp && !ignoreNoWhatsappFound) { + if (!defaultWhatsapp) { if (userId) { let whatsapps = await wbotByUserQueue({ userId, queueId }); @@ -53,13 +53,13 @@ const GetDefaultWhatsApp = async ({ where: { status: "CONNECTED" } }); } - } else { + } else { defaultWhatsapp = await Whatsapp.findOne({ where: { status: "CONNECTED", isOfficial: false } }); } - } - + } + if (!defaultWhatsapp && !ignoreNoWhatsappFound) { throw new AppError("ERR_NO_DEF_WAPP_FOUND"); } diff --git a/backend/src/services/WbotServices/CheckIsValidContact.ts b/backend/src/services/WbotServices/CheckIsValidContact.ts index d663206..bb1496c 100644 --- a/backend/src/services/WbotServices/CheckIsValidContact.ts +++ b/backend/src/services/WbotServices/CheckIsValidContact.ts @@ -30,6 +30,9 @@ const CheckIsValidContact = async ( let _status: any; if (!isValidNumber) { + + console.log('kkkkkkkkkkkkkkkkkkkkkkkkkkkkk ') + const { data, status } = await axios.post( `${process.env.WHATS_NUMBER_VALIDATOR_URL}/api/validate`, { mobile: number }, @@ -44,6 +47,8 @@ const CheckIsValidContact = async ( _status = status; } if (ignoreThrow) return isValidNumber?.number; + + console.log('_status: ', _status) if (_status && _status == 422) throw new AppError("ERR_NO_WAPP_FOUND");