chore: code otimization
parent
70f0fc992d
commit
5b4406584b
|
@ -344,8 +344,7 @@ const webhook_crm = async (req, res) => {
|
||||||
const sObject = req.body['soapenv:Envelope']['soapenv:Body']?.notifications?.Notification?.sObject
|
const sObject = req.body['soapenv:Envelope']['soapenv:Body']?.notifications?.Notification?.sObject
|
||||||
|
|
||||||
if (!sObject) {
|
if (!sObject) {
|
||||||
res.set('Content-Type', 'text/xml')
|
return res.set('Content-Type', 'text/xml').status(StatusCodes.OK).send(responseXml)
|
||||||
return res.status(StatusCodes.OK).send(responseXml)
|
|
||||||
}
|
}
|
||||||
|
|
||||||
const whoId = sObject['sf:WhoId']
|
const whoId = sObject['sf:WhoId']
|
||||||
|
@ -354,10 +353,10 @@ const webhook_crm = async (req, res) => {
|
||||||
|
|
||||||
|
|
||||||
console.log('==========> crm EventSubtype: ', EventSubtype)
|
console.log('==========> crm EventSubtype: ', EventSubtype)
|
||||||
console.log('==========> crm StartDateTime: ', StartDateTime)
|
console.log('==========> crm StartDateTime: ', StartDateTime)
|
||||||
console.log('==========> crm StartDateTime timeStamp: ', timeStamp(StartDateTime))
|
console.log('==========> crm StartDateTime timeStamp: ', timeStamp(StartDateTime))
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
if (EventSubtype == 'Event') {
|
if (EventSubtype == 'Event') {
|
||||||
|
|
||||||
|
@ -375,23 +374,20 @@ const webhook_crm = async (req, res) => {
|
||||||
const contactIdChatwoot = await getContactIdChatwoot(phone)
|
const contactIdChatwoot = await getContactIdChatwoot(phone)
|
||||||
|
|
||||||
if (!contactIdChatwoot) {
|
if (!contactIdChatwoot) {
|
||||||
res.set('Content-Type', 'text/xml')
|
return res.set('Content-Type', 'text/xml').status(StatusCodes.OK).send(responseXml)
|
||||||
return res.status(StatusCodes.OK).send(responseXml)
|
|
||||||
}
|
}
|
||||||
|
|
||||||
console.log('==========> crm contactIdChatwoot: ', contactIdChatwoot)
|
console.log('==========> crm contactIdChatwoot: ', contactIdChatwoot)
|
||||||
|
|
||||||
const ticketId = await createConversation(contactIdChatwoot)
|
const ticketId = await createConversation(contactIdChatwoot)
|
||||||
|
|
||||||
console.log('==========> crm ticketId: ', ticketId)
|
console.log('==========> crm ticketId: ', ticketId)
|
||||||
|
|
||||||
await toggleConversationStatus({ "status": "snoozed", "snoozed_until": timeStamp(StartDateTime) }, ticketId)
|
await toggleConversationStatus({ "status": "snoozed", "snoozed_until": timeStamp(StartDateTime) }, ticketId)
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
return res.set('Content-Type', 'text/xml').status(StatusCodes.OK).send(responseXml)
|
||||||
res.set('Content-Type', 'text/xml')
|
|
||||||
return res.status(StatusCodes.OK).send(responseXml)
|
|
||||||
}
|
}
|
||||||
|
|
||||||
module.exports = {
|
module.exports = {
|
||||||
|
|
Loading…
Reference in New Issue