From f05bfa4047fbb84348712848544e093f3b93f960 Mon Sep 17 00:00:00 2001 From: adriano Date: Fri, 20 Jun 2025 15:07:22 -0300 Subject: [PATCH] feat: implemented find companyId by omnihit accountId --- backend/controllers/crmController.js | 29 ++++------------------------ 1 file changed, 4 insertions(+), 25 deletions(-) diff --git a/backend/controllers/crmController.js b/backend/controllers/crmController.js index ecfc4ae..9c1ec89 100644 --- a/backend/controllers/crmController.js +++ b/backend/controllers/crmController.js @@ -436,29 +436,19 @@ const webhook = async (req, res) => { } let crmPhone = phone_number.replace('+', '') - const company = await Company.findOne({ integrations: { $elemMatch: { name: "omnihit", - "config.accountId": accountId + "config.accountId": `${accountId}` } } }) if (!company) { return res.status(StatusCodes.NOT_FOUND).send({ msg: "companyId not found!" }) - } - - 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) + } console.log('=======> name: ', name) console.log('=======> crmPhone: ', crmPhone) @@ -533,9 +523,7 @@ const webhook_crm = async (req, res) => { if (!contact) return res.send() - const { phone } = contact - - // const obj = omnihitV2Integration.find(o => o.companyId == companyId) + const { phone } = contact const config = await getIntegrationsConfig(companyId, 'omnihit') @@ -565,16 +553,7 @@ const webhook_crm = async (req, res) => { } return res.set('Content-Type', 'text/xml').status(StatusCodes.OK).send(responseXml) -} - -const integration = async (req, res) => { - const { companyId } = req.query - const { integration } = req.body - - console.log("====> companyId: ", companyId, " | integration: ", integration) - - res.send() -} +} module.exports = { contactCreate,