diff --git a/backend/controllers/crmController.js b/backend/controllers/crmController.js index 7c73e0b..ecfc4ae 100644 --- a/backend/controllers/crmController.js +++ b/backend/controllers/crmController.js @@ -437,39 +437,39 @@ const webhook = async (req, res) => { let crmPhone = phone_number.replace('+', '') - - // TEST + const company = await Company.findOne({ integrations: { $elemMatch: { name: "omnihit", - "config.accountId": "15" + "config.accountId": accountId } } }) - console.log("======> company omnihit: ", company) - // + if (!company) { + return res.status(StatusCodes.NOT_FOUND).send({ msg: "companyId not found!" }) + } - const companies = [ - // { companyId: "99", account_id: "1" }, - { companyId: "99", account_id: "15" }, - ] + console.log("======> company omnihit: ", company) + // const companies = [ + // // { companyId: "99", account_id: "1" }, + // { companyId: "99", account_id: "15" }, + // ] - - const obj = companies.find(c => +c.account_id == +accountId) + // const obj = companies.find(c => +c.account_id == +accountId) console.log('=======> name: ', name) console.log('=======> crmPhone: ', crmPhone) console.log('=======> accountId: ', accountId) - console.log('=======> companyId: ', obj.companyId) + console.log('=======> companyId: ', company.companyId) console.log('=======> ticketId: ', ticketId) await whatsappJournalingCRM( - companyId = obj.companyId, + companyId = company.companyId, crmPhone = crmPhone, crmAgent = '0000', crmFirstName = name,