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
|
||||
|
||||
if (!sObject) {
|
||||
res.set('Content-Type', 'text/xml')
|
||||
return res.status(StatusCodes.OK).send(responseXml)
|
||||
return res.set('Content-Type', 'text/xml').status(StatusCodes.OK).send(responseXml)
|
||||
}
|
||||
|
||||
const whoId = sObject['sf:WhoId']
|
||||
|
@ -354,10 +353,10 @@ const webhook_crm = async (req, res) => {
|
|||
|
||||
|
||||
console.log('==========> crm EventSubtype: ', EventSubtype)
|
||||
console.log('==========> crm StartDateTime: ', StartDateTime)
|
||||
console.log('==========> crm StartDateTime timeStamp: ', timeStamp(StartDateTime))
|
||||
console.log('==========> crm StartDateTime: ', StartDateTime)
|
||||
console.log('==========> crm StartDateTime timeStamp: ', timeStamp(StartDateTime))
|
||||
|
||||
|
||||
|
||||
|
||||
if (EventSubtype == 'Event') {
|
||||
|
||||
|
@ -375,23 +374,20 @@ const webhook_crm = async (req, res) => {
|
|||
const contactIdChatwoot = await getContactIdChatwoot(phone)
|
||||
|
||||
if (!contactIdChatwoot) {
|
||||
res.set('Content-Type', 'text/xml')
|
||||
return res.status(StatusCodes.OK).send(responseXml)
|
||||
return res.set('Content-Type', 'text/xml').status(StatusCodes.OK).send(responseXml)
|
||||
}
|
||||
|
||||
console.log('==========> crm contactIdChatwoot: ', 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)
|
||||
|
||||
}
|
||||
|
||||
|
||||
res.set('Content-Type', 'text/xml')
|
||||
return res.status(StatusCodes.OK).send(responseXml)
|
||||
return res.set('Content-Type', 'text/xml').status(StatusCodes.OK).send(responseXml)
|
||||
}
|
||||
|
||||
module.exports = {
|
||||
|
|
Loading…
Reference in New Issue