Built motion from commit 0900f080.|2.5.45
[motion2.git] / server / api / whatsappMessage / whatsappMessage.controller.js
index 84c60ca..e2ce2c2 100644 (file)
@@ -15,4 +15,4 @@
 // * treaties. The SOFTWARE PRODUCT is licensed, not sold.                        *
 // *                                                                       *
 // *************************************************************************
-var _0xb1f7=['request-promise','moment','bluebird','mustache','util','path','sox','to-csv','ejs','fs-extra','lodash','squel','crypto','jsforce','desk.js','querystring','papaparse','ioredis','../../config/license/hardware','../../config/logger','api','../../config/environment','../../config/license/util','../../mysqldb','redis','localhost','socket.io-emitter','./whatsappMessage.socket','register','client','http','then','info','request\x20sent','WhatsappMessage,\x20%s,\x20%s,\x20%s','stringify','error','WhatsappMessage,\x20%s,\x20%s','message','result','catch','sendStatus','status','end','json','offset','limit','undefined','count','set','apply','reject','save','update','destroy','stack','name','send','map','rawAttributes','fieldName','type','key','model','query','filters','intersection','attributes','fields','hasOwnProperty','nolimit','sort','where','pick','merge','filter','include','WhatsappMessage','rows','show','params','keys','includeAll','options','create','body','find','whatsapp-interactions','whatsapp','read','readAt','format','YYYY-MM-DD\x20HH:mm:ss','UserId','user','agent','get','WhatsappInteractionId','isNil','read1stAt','[WHATSAPPMESSAGE:ACCEPT]\x20id=%s\x20name=%s\x20role=%s\x20interaction=%s\x20body=%s','null','AcceptMessage','SELECT\x20*\x20FROM\x20cm_contacts\x20WHERE\x20id\x20=\x20','ContactId','sequelize','SELECT','contact','User','fullname','email','internal','manual','interface','channel','event','accept','EventManager','interaction','[WHATSAPPMESSAGE:REJECT]\x20id=%s\x20name=%s\x20role=%s\x20interaction=%s\x20body=%s','role','RejectMessage','Sequelize','QueryTypes','SIP/%s','rejectmessage','WhatsappAccount','WhatsappAccountId','debug','WhatsppMessage,\x20%s,\x20%s,\x20%s','received\x20delivery\x20report\x20from','twilio','messageId','MessageStatus','inspect','eml-format','rimraf','zip-dir','fast-json-patch'];(function(_0x1e8b66,_0x5509f9){var _0x2d1ce3=function(_0x16ebc4){while(--_0x16ebc4){_0x1e8b66['push'](_0x1e8b66['shift']());}};_0x2d1ce3(++_0x5509f9);}(_0xb1f7,0x19d));var _0x7b1f=function(_0x706f88,_0x28af24){_0x706f88=_0x706f88-0x0;var _0x4f850a=_0xb1f7[_0x706f88];return _0x4f850a;};'use strict';var emlformat=require(_0x7b1f('0x0'));var rimraf=require(_0x7b1f('0x1'));var zipdir=require(_0x7b1f('0x2'));var jsonpatch=require(_0x7b1f('0x3'));var rp=require(_0x7b1f('0x4'));var moment=require(_0x7b1f('0x5'));var BPromise=require(_0x7b1f('0x6'));var Mustache=require(_0x7b1f('0x7'));var util=require(_0x7b1f('0x8'));var path=require(_0x7b1f('0x9'));var sox=require(_0x7b1f('0xa'));var csv=require(_0x7b1f('0xb'));var ejs=require(_0x7b1f('0xc'));var fs=require('fs');var fs_extra=require(_0x7b1f('0xd'));var _=require(_0x7b1f('0xe'));var squel=require(_0x7b1f('0xf'));var crypto=require(_0x7b1f('0x10'));var jsforce=require(_0x7b1f('0x11'));var deskjs=require(_0x7b1f('0x12'));var toCsv=require(_0x7b1f('0xb'));var querystring=require(_0x7b1f('0x13'));var Papa=require(_0x7b1f('0x14'));var Redis=require(_0x7b1f('0x15'));var authService=require('../../components/auth/service');var qs=require('../../components/parsers/qs');var as=require('../../components/parsers/advancedSearch');var hardwareService=require(_0x7b1f('0x16'));var logger=require(_0x7b1f('0x17'))(_0x7b1f('0x18'));var utils=require('../../config/utils');var config=require(_0x7b1f('0x19'));var licenseUtil=require(_0x7b1f('0x1a'));var db=require(_0x7b1f('0x1b'))['db'];config[_0x7b1f('0x1c')]=_['defaults'](config[_0x7b1f('0x1c')],{'host':_0x7b1f('0x1d'),'port':0x18eb});var socket=require(_0x7b1f('0x1e'))(new Redis(config[_0x7b1f('0x1c')]));require(_0x7b1f('0x1f'))[_0x7b1f('0x20')](socket);var jayson=require('jayson/promise');var client=jayson[_0x7b1f('0x21')]['http']({'port':0x232c});var client9002=jayson[_0x7b1f('0x21')][_0x7b1f('0x22')]({'port':0x232a});function respondWithRpcPromise(_0x244ceb,_0x3966f2,_0x5a613a,_0x9ffba5){return new BPromise(function(_0x30bb69,_0x5608e6){var _0x5d3ef2=_0x9ffba5||client;return _0x5d3ef2['request'](_0x244ceb,_0x5a613a)[_0x7b1f('0x23')](function(_0x3b768b){logger[_0x7b1f('0x24')]('WhatsappMessage,\x20%s,\x20%s',_0x3966f2,_0x7b1f('0x25'));logger['debug'](_0x7b1f('0x26'),_0x3966f2,_0x7b1f('0x25'),JSON[_0x7b1f('0x27')](_0x3b768b));if(_0x3b768b['error']){if(_0x3b768b[_0x7b1f('0x28')]['code']===0x1f4){logger[_0x7b1f('0x28')](_0x7b1f('0x29'),_0x3966f2,_0x3b768b[_0x7b1f('0x28')][_0x7b1f('0x2a')]);return _0x5608e6(_0x3b768b['error']['message']);}logger[_0x7b1f('0x28')]('WhatsappMessage,\x20%s,\x20%s',_0x3966f2,_0x3b768b[_0x7b1f('0x28')][_0x7b1f('0x2a')]);return _0x30bb69(_0x3b768b[_0x7b1f('0x28')]['message']);}else{logger['info'](_0x7b1f('0x29'),_0x3966f2,'request\x20sent');_0x30bb69(_0x3b768b[_0x7b1f('0x2b')][_0x7b1f('0x2a')]);}})[_0x7b1f('0x2c')](function(_0x5de8e2){logger[_0x7b1f('0x28')](_0x7b1f('0x29'),_0x3966f2,_0x5de8e2);_0x5608e6(_0x5de8e2);});});}function respondWithStatusCode(_0x299df8,_0x305fc4){_0x305fc4=_0x305fc4||0xcc;return function(_0x58033b){if(_0x58033b){return _0x299df8[_0x7b1f('0x2d')](_0x305fc4);}return _0x299df8[_0x7b1f('0x2e')](_0x305fc4)[_0x7b1f('0x2f')]();};}function respondWithResult(_0xf3764a,_0x4878eb){_0x4878eb=_0x4878eb||0xc8;return function(_0x365a88){if(_0x365a88){return _0xf3764a[_0x7b1f('0x2e')](_0x4878eb)[_0x7b1f('0x30')](_0x365a88);}};}function respondWithFilteredResult(_0x46842d,_0x455f0a){return function(_0x4be6da){if(_0x4be6da){var _0x30a07e=typeof _0x455f0a[_0x7b1f('0x31')]==='undefined'&&typeof _0x455f0a[_0x7b1f('0x32')]===_0x7b1f('0x33');var _0x1d9a17=_0x4be6da[_0x7b1f('0x34')];var _0x7eb9d3=_0x30a07e?0x0:_0x455f0a['offset'];var _0xadc0c5=_0x30a07e?_0x4be6da[_0x7b1f('0x34')]:_0x455f0a[_0x7b1f('0x31')]+_0x455f0a[_0x7b1f('0x32')];var _0x1d2340;if(_0xadc0c5>=_0x1d9a17){_0xadc0c5=_0x1d9a17;_0x1d2340=0xc8;}else{_0x1d2340=0xce;}_0x46842d[_0x7b1f('0x2e')](_0x1d2340);return _0x46842d[_0x7b1f('0x35')]('Content-Range',_0x7eb9d3+'-'+_0xadc0c5+'/'+_0x1d9a17)[_0x7b1f('0x30')](_0x4be6da);}return null;};}function patchUpdates(_0x40c658){return function(_0xa9bc63){try{jsonpatch[_0x7b1f('0x36')](_0xa9bc63,_0x40c658,!![]);}catch(_0x4f5f88){return BPromise[_0x7b1f('0x37')](_0x4f5f88);}return _0xa9bc63[_0x7b1f('0x38')]();};}function saveUpdates(_0x1b969c,_0x35260c){return function(_0x1d3636){if(_0x1d3636){return _0x1d3636[_0x7b1f('0x39')](_0x1b969c)['then'](function(_0x5d9f30){return _0x5d9f30;});}return null;};}function removeEntity(_0x1d9edb,_0x2562b3){return function(_0x4f2979){if(_0x4f2979){return _0x4f2979[_0x7b1f('0x3a')]()['then'](function(){_0x1d9edb[_0x7b1f('0x2e')](0xcc)[_0x7b1f('0x2f')]();});}};}function handleEntityNotFound(_0x4a984d,_0x291038){return function(_0x31669a){if(!_0x31669a){_0x4a984d[_0x7b1f('0x2d')](0x194);}return _0x31669a;};}function handleError(_0x41f1b2,_0x6fdd48){_0x6fdd48=_0x6fdd48||0x1f4;return function(_0x4f6944){logger[_0x7b1f('0x28')](_0x4f6944[_0x7b1f('0x3b')]);if(_0x4f6944[_0x7b1f('0x3c')]){delete _0x4f6944[_0x7b1f('0x3c')];}_0x41f1b2['status'](_0x6fdd48)[_0x7b1f('0x3d')](_0x4f6944);};}exports['index']=function(_0x6d610e,_0x4eec24){var _0x4a8d93={},_0x2b06ca={},_0x510814={'count':0x0,'rows':[]};var _0x5adeb1=_[_0x7b1f('0x3e')](db['WhatsappMessage'][_0x7b1f('0x3f')],function(_0x24248c){return{'name':_0x24248c[_0x7b1f('0x40')],'type':_0x24248c[_0x7b1f('0x41')][_0x7b1f('0x42')]};});_0x2b06ca[_0x7b1f('0x43')]=_[_0x7b1f('0x3e')](_0x5adeb1,_0x7b1f('0x3c'));_0x2b06ca['query']=_['keys'](_0x6d610e[_0x7b1f('0x44')]);_0x2b06ca[_0x7b1f('0x45')]=_[_0x7b1f('0x46')](_0x2b06ca[_0x7b1f('0x43')],_0x2b06ca[_0x7b1f('0x44')]);_0x4a8d93[_0x7b1f('0x47')]=_['intersection'](_0x2b06ca[_0x7b1f('0x43')],qs[_0x7b1f('0x48')](_0x6d610e[_0x7b1f('0x44')][_0x7b1f('0x48')]));_0x4a8d93[_0x7b1f('0x47')]=_0x4a8d93[_0x7b1f('0x47')]['length']?_0x4a8d93[_0x7b1f('0x47')]:_0x2b06ca[_0x7b1f('0x43')];if(!_0x6d610e[_0x7b1f('0x44')][_0x7b1f('0x49')](_0x7b1f('0x4a'))){_0x4a8d93[_0x7b1f('0x32')]=qs[_0x7b1f('0x32')](_0x6d610e[_0x7b1f('0x44')][_0x7b1f('0x32')]);_0x4a8d93['offset']=qs[_0x7b1f('0x31')](_0x6d610e[_0x7b1f('0x44')][_0x7b1f('0x31')]);}_0x4a8d93['order']=qs[_0x7b1f('0x4b')](_0x6d610e['query'][_0x7b1f('0x4b')]);_0x4a8d93[_0x7b1f('0x4c')]=qs[_0x7b1f('0x45')](_[_0x7b1f('0x4d')](_0x6d610e[_0x7b1f('0x44')],_0x2b06ca[_0x7b1f('0x45')]),_0x5adeb1);if(_0x6d610e[_0x7b1f('0x44')]['filter']){_0x4a8d93[_0x7b1f('0x4c')]=_[_0x7b1f('0x4e')](_0x4a8d93[_0x7b1f('0x4c')],{'$or':_[_0x7b1f('0x3e')](_0x5adeb1,function(_0x10497d){if(_0x10497d[_0x7b1f('0x41')]!=='VIRTUAL'){var _0x3f2116={};_0x3f2116[_0x10497d[_0x7b1f('0x3c')]]={'$like':'%'+_0x6d610e[_0x7b1f('0x44')][_0x7b1f('0x4f')]+'%'};return _0x3f2116;}})});}_0x4a8d93=_[_0x7b1f('0x4e')]({},_0x4a8d93,_0x6d610e['options']);var _0x5a8c09={'where':_0x4a8d93['where']};return db['WhatsappMessage'][_0x7b1f('0x34')](_0x5a8c09)[_0x7b1f('0x23')](function(_0x1baceb){_0x510814[_0x7b1f('0x34')]=_0x1baceb;if(_0x6d610e['query']['includeAll']){_0x4a8d93[_0x7b1f('0x50')]=[{'all':!![]}];}return db[_0x7b1f('0x51')]['findAll'](_0x4a8d93);})[_0x7b1f('0x23')](function(_0x5d1be2){_0x510814[_0x7b1f('0x52')]=_0x5d1be2;return _0x510814;})['then'](respondWithFilteredResult(_0x4eec24,_0x4a8d93))[_0x7b1f('0x2c')](handleError(_0x4eec24,null));};exports[_0x7b1f('0x53')]=function(_0x16bbc0,_0x391b82){var _0x268773={'raw':!![],'where':{'id':_0x16bbc0[_0x7b1f('0x54')]['id']}},_0xf5d132={};_0xf5d132['model']=_[_0x7b1f('0x55')](db[_0x7b1f('0x51')][_0x7b1f('0x3f')]);_0xf5d132['query']=_['keys'](_0x16bbc0[_0x7b1f('0x44')]);_0xf5d132[_0x7b1f('0x45')]=_['intersection'](_0xf5d132[_0x7b1f('0x43')],_0xf5d132[_0x7b1f('0x44')]);_0x268773[_0x7b1f('0x47')]=_['intersection'](_0xf5d132[_0x7b1f('0x43')],qs[_0x7b1f('0x48')](_0x16bbc0[_0x7b1f('0x44')]['fields']));_0x268773[_0x7b1f('0x47')]=_0x268773[_0x7b1f('0x47')]['length']?_0x268773['attributes']:_0xf5d132['model'];if(_0x16bbc0[_0x7b1f('0x44')][_0x7b1f('0x56')]){_0x268773[_0x7b1f('0x50')]=[{'all':!![]}];}_0x268773=_[_0x7b1f('0x4e')]({},_0x268773,_0x16bbc0[_0x7b1f('0x57')]);return db[_0x7b1f('0x51')]['find'](_0x268773)['then'](handleEntityNotFound(_0x391b82,null))['then'](respondWithResult(_0x391b82,null))[_0x7b1f('0x2c')](handleError(_0x391b82,null));};exports[_0x7b1f('0x58')]=function(_0x2e1103,_0x1a952d){return db[_0x7b1f('0x51')][_0x7b1f('0x58')](_0x2e1103[_0x7b1f('0x59')],{})[_0x7b1f('0x23')](respondWithResult(_0x1a952d,0xc9))[_0x7b1f('0x2c')](handleError(_0x1a952d,null));};exports[_0x7b1f('0x39')]=function(_0x42dd71,_0x2fdfb1){if(_0x42dd71['body']['id']){delete _0x42dd71['body']['id'];}return db[_0x7b1f('0x51')][_0x7b1f('0x5a')]({'where':{'id':_0x42dd71[_0x7b1f('0x54')]['id']}})[_0x7b1f('0x23')](handleEntityNotFound(_0x2fdfb1,null))[_0x7b1f('0x23')](saveUpdates(_0x42dd71[_0x7b1f('0x59')],null))['then'](respondWithResult(_0x2fdfb1,null))['catch'](handleError(_0x2fdfb1,null));};exports[_0x7b1f('0x3a')]=function(_0xe88bc7,_0x58811b){return db[_0x7b1f('0x51')][_0x7b1f('0x5a')]({'where':{'id':_0xe88bc7['params']['id']}})[_0x7b1f('0x23')](handleEntityNotFound(_0x58811b,null))['then'](removeEntity(_0x58811b,null))[_0x7b1f('0x2c')](handleError(_0x58811b,null));};exports['describe']=function(_0x243f78,_0x3c630b){return db[_0x7b1f('0x51')]['describe']()[_0x7b1f('0x23')](respondWithResult(_0x3c630b,null))[_0x7b1f('0x2c')](handleError(_0x3c630b,null));};var interaction_log=require(_0x7b1f('0x17'))(_0x7b1f('0x5b'));exports['accept']=function(_0x13586c,_0x6fd736,_0x3d6d07){var _0x2b7519={'agent':{},'channel':_0x7b1f('0x5c')};if(_0x13586c[_0x7b1f('0x59')]['id']){delete _0x13586c[_0x7b1f('0x59')]['id'];}_0x13586c['body'][_0x7b1f('0x5d')]=!![];_0x13586c[_0x7b1f('0x59')][_0x7b1f('0x5e')]=moment()[_0x7b1f('0x5f')](_0x7b1f('0x60'));_0x13586c['body']['UserId']=_0x13586c[_0x7b1f('0x59')][_0x7b1f('0x61')]||_0x13586c[_0x7b1f('0x62')]['id'];_0x2b7519[_0x7b1f('0x63')]['id']=_0x13586c[_0x7b1f('0x59')][_0x7b1f('0x61')];return db[_0x7b1f('0x51')]['find']({'where':{'id':_0x13586c[_0x7b1f('0x54')]['id'],'UserId':null}})[_0x7b1f('0x23')](handleEntityNotFound(_0x6fd736,null))[_0x7b1f('0x23')](saveUpdates(_0x13586c[_0x7b1f('0x59')],null))[_0x7b1f('0x23')](function(_0x38bd05){if(_0x38bd05){_0x2b7519['message']=_0x38bd05[_0x7b1f('0x64')]({'plain':!![]});return db['WhatsappInteraction'][_0x7b1f('0x5a')]({'where':{'id':_0x38bd05[_0x7b1f('0x65')]}});}return null;})[_0x7b1f('0x23')](handleEntityNotFound(_0x6fd736,null))['then'](function(_0x6ceb8a){if(_0x6ceb8a){return _0x6ceb8a[_0x7b1f('0x39')]({'UserId':_0x13586c['body']['UserId'],'read1stAt':_[_0x7b1f('0x66')](_0x6ceb8a[_0x7b1f('0x67')])?moment()[_0x7b1f('0x5f')](_0x7b1f('0x60')):undefined});}return null;})['then'](function(_0x30afc0){if(_0x30afc0){_0x2b7519['interaction']=_0x30afc0[_0x7b1f('0x64')]({'plain':!![]});interaction_log['info'](_0x7b1f('0x68'),_0x13586c[_0x7b1f('0x62')]['id'],_0x13586c['user'][_0x7b1f('0x3c')],_0x13586c[_0x7b1f('0x62')]['role'],_0x2b7519['interaction']['id'],_0x13586c[_0x7b1f('0x59')]?JSON[_0x7b1f('0x27')](_0x13586c[_0x7b1f('0x59')]):_0x7b1f('0x69'));return respondWithRpcPromise(_0x7b1f('0x6a'),'acceptMessage',_0x2b7519);}return null;})[_0x7b1f('0x23')](function(_0x530ee5){var _0xee223b=_0x7b1f('0x6b')+_0x530ee5[_0x7b1f('0x2a')][_0x7b1f('0x6c')];return db[_0x7b1f('0x6d')][_0x7b1f('0x44')](_0xee223b,{'type':db['Sequelize']['QueryTypes'][_0x7b1f('0x6e')],'raw':!![]})['then'](function(_0x7f8db6){return _0x7f8db6;});})[_0x7b1f('0x23')](function(_0x16a3cc){if(_0x16a3cc){_0x2b7519['message'][_0x7b1f('0x6f')]=_0x16a3cc[0x0];if(!_0x13586c[_0x7b1f('0x59')][_0x7b1f('0x61')])return;return db[_0x7b1f('0x70')][_0x7b1f('0x5a')]({'where':{'id':_0x13586c[_0x7b1f('0x59')]['UserId'],'role':'agent'},'attributes':['id','name',_0x7b1f('0x71'),_0x7b1f('0x72'),_0x7b1f('0x73')],'raw':!![]});}return null;})[_0x7b1f('0x23')](function(_0x333a1c){if(!_0x333a1c)return null;_0x2b7519[_0x7b1f('0x2a')][_0x7b1f('0x63')]=_0x333a1c;return _0x2b7519;})[_0x7b1f('0x23')](function(_0x4b1fa9){if(_0x4b1fa9){if(_0x13586c['body'][_0x7b1f('0x74')]){_0x2b7519[_0x7b1f('0x2a')][_0x7b1f('0x75')]=util[_0x7b1f('0x5f')]('SIP/%s',_0x13586c[_0x7b1f('0x62')][_0x7b1f('0x3c')]);_0x2b7519['message'][_0x7b1f('0x76')]=_0x2b7519[_0x7b1f('0x76')];_0x2b7519[_0x7b1f('0x2a')][_0x7b1f('0x77')]=_0x7b1f('0x78');return respondWithRpcPromise(_0x7b1f('0x79'),_0x7b1f('0x79'),{'event':'acceptmessage','message':_0x2b7519['message']},client9002)[_0x7b1f('0x23')](function(){return _0x2b7519;});}return _0x2b7519;}return null;})[_0x7b1f('0x23')](respondWithResult(_0x6fd736,null))['catch'](handleError(_0x6fd736,null));};var interaction_log=require(_0x7b1f('0x17'))(_0x7b1f('0x5b'));exports[_0x7b1f('0x37')]=function(_0x270b01,_0x73e115,_0x19f85d){var _0x188e2e={'agent':{},'channel':'whatsapp'};if(_0x270b01[_0x7b1f('0x59')]['id']){delete _0x270b01[_0x7b1f('0x59')]['id'];}_0x270b01[_0x7b1f('0x59')]['UserId']=_0x270b01[_0x7b1f('0x59')][_0x7b1f('0x61')]||_0x270b01[_0x7b1f('0x62')]['id'];_0x188e2e[_0x7b1f('0x63')]['id']=_0x270b01['body'][_0x7b1f('0x61')];return db[_0x7b1f('0x51')]['find']({'where':{'id':_0x270b01['params']['id'],'UserId':null}})[_0x7b1f('0x23')](handleEntityNotFound(_0x73e115,null))[_0x7b1f('0x23')](function(_0x374202){if(_0x374202){_0x188e2e[_0x7b1f('0x2a')]=_0x374202[_0x7b1f('0x64')]({'plain':!![]});return db['WhatsappInteraction'][_0x7b1f('0x5a')]({'where':{'id':_0x374202[_0x7b1f('0x65')]}});}return null;})[_0x7b1f('0x23')](handleEntityNotFound(_0x73e115,null))[_0x7b1f('0x23')](function(_0x5ddae0){if(_0x5ddae0){_0x188e2e[_0x7b1f('0x7a')]=_0x5ddae0[_0x7b1f('0x64')]({'plain':!![]});interaction_log[_0x7b1f('0x24')](_0x7b1f('0x7b'),_0x270b01[_0x7b1f('0x62')]['id'],_0x270b01[_0x7b1f('0x62')][_0x7b1f('0x3c')],_0x270b01[_0x7b1f('0x62')][_0x7b1f('0x7c')],_0x188e2e[_0x7b1f('0x7a')]['id'],_0x270b01[_0x7b1f('0x59')]?JSON[_0x7b1f('0x27')](_0x270b01['body']):_0x7b1f('0x69'));return respondWithRpcPromise(_0x7b1f('0x7d'),'rejectMessage',_0x188e2e);}return null;})[_0x7b1f('0x23')](function(_0x13468b){var _0x47c4e4=_0x7b1f('0x6b')+_0x13468b[_0x7b1f('0x2a')][_0x7b1f('0x6c')];return db[_0x7b1f('0x6d')]['query'](_0x47c4e4,{'type':db[_0x7b1f('0x7e')][_0x7b1f('0x7f')]['SELECT'],'raw':!![]})[_0x7b1f('0x23')](function(_0x3ea1b4){return _0x3ea1b4;});})[_0x7b1f('0x23')](function(_0x364c07){if(_0x364c07){_0x188e2e['message']['contact']=_0x364c07[0x0];if(!_0x270b01['body'][_0x7b1f('0x61')])return;return db[_0x7b1f('0x70')][_0x7b1f('0x5a')]({'where':{'id':_0x270b01[_0x7b1f('0x59')]['UserId'],'role':_0x7b1f('0x63')},'attributes':['id',_0x7b1f('0x3c'),_0x7b1f('0x71'),_0x7b1f('0x72'),'internal'],'raw':!![]});}return null;})[_0x7b1f('0x23')](function(_0x4a0c8c){if(!_0x4a0c8c)return null;_0x188e2e[_0x7b1f('0x2a')][_0x7b1f('0x63')]=_0x4a0c8c;return _0x188e2e;})[_0x7b1f('0x23')](function(_0x552201){if(_0x552201){_0x552201['message'][_0x7b1f('0x75')]=util[_0x7b1f('0x5f')](_0x7b1f('0x80'),_0x270b01[_0x7b1f('0x62')][_0x7b1f('0x3c')]);_0x552201[_0x7b1f('0x2a')][_0x7b1f('0x76')]=_0x188e2e['channel'];_0x552201['message'][_0x7b1f('0x77')]=_0x7b1f('0x37');respondWithRpcPromise(_0x7b1f('0x79'),_0x7b1f('0x79'),{'event':_0x7b1f('0x81'),'message':_0x552201[_0x7b1f('0x2a')]},client9002);return _0x188e2e;}return null;})[_0x7b1f('0x23')](respondWithResult(_0x73e115,null))[_0x7b1f('0x2c')](handleError(_0x73e115,null));};exports[_0x7b1f('0x2e')]=function(_0xea3d1a,_0x8abd73,_0x418c7c){if(_0xea3d1a['body']['id']){delete _0xea3d1a[_0x7b1f('0x59')]['id'];}var _0x432ae7;return db['WhatsappMessage'][_0x7b1f('0x5a')]({'where':{'id':_0xea3d1a[_0x7b1f('0x54')]['id']}})[_0x7b1f('0x23')](handleEntityNotFound(_0x8abd73,null))[_0x7b1f('0x23')](function(_0x227656){if(_0x227656){_0x432ae7=_0x227656;return db[_0x7b1f('0x82')]['find']({'where':{'id':_0x227656[_0x7b1f('0x83')]}});}})[_0x7b1f('0x23')](handleEntityNotFound(_0x8abd73,null))[_0x7b1f('0x23')](function(_0x427ca7){if(_0x427ca7){logger[_0x7b1f('0x84')](_0x7b1f('0x85'),_0x7b1f('0x2e'),_0x7b1f('0x86'),_0x427ca7['type'],util['inspect'](_0xea3d1a[_0x7b1f('0x59')],{'showHidden':![],'depth':null}));switch(_0x427ca7[_0x7b1f('0x41')]){case _0x7b1f('0x87'):if(_0xea3d1a[_0x7b1f('0x59')]['MessageSid']&&_0xea3d1a[_0x7b1f('0x59')]['MessageSid']===_0x432ae7[_0x7b1f('0x88')]&&_0xea3d1a[_0x7b1f('0x59')][_0x7b1f('0x89')]&&_0xea3d1a[_0x7b1f('0x59')][_0x7b1f('0x89')]===_0x7b1f('0x5d')){return _0x432ae7[_0x7b1f('0x39')]({'read':!![]});}else{logger[_0x7b1f('0x28')]('WhatsappAccount,\x20%s,\x20%s,\x20%s',_0x7b1f('0x2e'),'twilio',util[_0x7b1f('0x8a')](_0xea3d1a['body'],{'showHidden':![],'depth':null}));}break;}return _0x432ae7;}})[_0x7b1f('0x23')](respondWithResult(_0x8abd73,null))['catch'](handleError(_0x8abd73,null));};
\ No newline at end of file
+var _0x680c=['rawAttributes','type','query','keys','filters','intersection','model','fields','attributes','length','order','sort','where','merge','filter','WhatsappMessage','includeAll','rows','show','include','find','create','update','body','params','describe','whatsapp-interactions','accept','whatsapp','read','readAt','format','YYYY-MM-DD\x20HH:mm:ss','UserId','user','agent','get','WhatsappInteraction','WhatsappInteractionId','isNil','read1stAt','interaction','info','[WHATSAPPMESSAGE:ACCEPT]\x20id=%s\x20name=%s\x20role=%s\x20interaction=%s\x20body=%s','role','stringify','null','acceptMessage','SELECT\x20*\x20FROM\x20cm_contacts\x20WHERE\x20id\x20=\x20','ContactId','QueryTypes','SELECT','User','fullname','manual','interface','SIP/%s','channel','motionChannel','event','EventManager','acceptmessage','RejectMessage','rejectMessage','sequelize','Sequelize','contact','email','internal','WhatsappAccount','WhatsappAccountId','WhatsppMessage,\x20%s,\x20%s,\x20%s','inspect','twilio','MessageSid','messageId','MessageStatus','WhatsappAccount,\x20%s,\x20%s,\x20%s','eml-format','zip-dir','fast-json-patch','request-promise','moment','bluebird','mustache','path','to-csv','ejs','lodash','squel','crypto','jsforce','desk.js','querystring','papaparse','ioredis','../../components/parsers/advancedSearch','../../config/license/hardware','../../config/logger','api','../../config/utils','../../config/environment','../../config/license/util','../../mysqldb','defaults','redis','socket.io-emitter','./whatsappMessage.socket','register','client','http','request','then','request\x20sent','debug','WhatsappMessage,\x20%s,\x20%s,\x20%s','error','code','WhatsappMessage,\x20%s,\x20%s','message','result','catch','status','json','offset','undefined','count','limit','set','Content-Range','reject','destroy','sendStatus','stack','name','index','map'];(function(_0x2acd24,_0xf315ac){var _0x546099=function(_0x479e66){while(--_0x479e66){_0x2acd24['push'](_0x2acd24['shift']());}};_0x546099(++_0xf315ac);}(_0x680c,0x160));var _0xc680=function(_0x4c1917,_0xea7b6c){_0x4c1917=_0x4c1917-0x0;var _0x220fa5=_0x680c[_0x4c1917];return _0x220fa5;};'use strict';var emlformat=require(_0xc680('0x0'));var rimraf=require('rimraf');var zipdir=require(_0xc680('0x1'));var jsonpatch=require(_0xc680('0x2'));var rp=require(_0xc680('0x3'));var moment=require(_0xc680('0x4'));var BPromise=require(_0xc680('0x5'));var Mustache=require(_0xc680('0x6'));var util=require('util');var path=require(_0xc680('0x7'));var sox=require('sox');var csv=require(_0xc680('0x8'));var ejs=require(_0xc680('0x9'));var fs=require('fs');var fs_extra=require('fs-extra');var _=require(_0xc680('0xa'));var squel=require(_0xc680('0xb'));var crypto=require(_0xc680('0xc'));var jsforce=require(_0xc680('0xd'));var deskjs=require(_0xc680('0xe'));var toCsv=require(_0xc680('0x8'));var querystring=require(_0xc680('0xf'));var Papa=require(_0xc680('0x10'));var Redis=require(_0xc680('0x11'));var authService=require('../../components/auth/service');var qs=require('../../components/parsers/qs');var as=require(_0xc680('0x12'));var hardwareService=require(_0xc680('0x13'));var logger=require(_0xc680('0x14'))(_0xc680('0x15'));var utils=require(_0xc680('0x16'));var config=require(_0xc680('0x17'));var licenseUtil=require(_0xc680('0x18'));var db=require(_0xc680('0x19'))['db'];config['redis']=_[_0xc680('0x1a')](config[_0xc680('0x1b')],{'host':'localhost','port':0x18eb});var socket=require(_0xc680('0x1c'))(new Redis(config[_0xc680('0x1b')]));require(_0xc680('0x1d'))[_0xc680('0x1e')](socket);var jayson=require('jayson/promise');var client=jayson[_0xc680('0x1f')][_0xc680('0x20')]({'port':0x232c});var client9002=jayson[_0xc680('0x1f')][_0xc680('0x20')]({'port':0x232a});function respondWithRpcPromise(_0x5e6741,_0x3cad4f,_0x57e497,_0x26d2be){return new BPromise(function(_0x2cd697,_0x5ada10){var _0x416252=_0x26d2be||client;return _0x416252[_0xc680('0x21')](_0x5e6741,_0x57e497)[_0xc680('0x22')](function(_0x4b6214){logger['info']('WhatsappMessage,\x20%s,\x20%s',_0x3cad4f,_0xc680('0x23'));logger[_0xc680('0x24')](_0xc680('0x25'),_0x3cad4f,_0xc680('0x23'),JSON['stringify'](_0x4b6214));if(_0x4b6214[_0xc680('0x26')]){if(_0x4b6214[_0xc680('0x26')][_0xc680('0x27')]===0x1f4){logger['error'](_0xc680('0x28'),_0x3cad4f,_0x4b6214[_0xc680('0x26')]['message']);return _0x5ada10(_0x4b6214[_0xc680('0x26')][_0xc680('0x29')]);}logger[_0xc680('0x26')]('WhatsappMessage,\x20%s,\x20%s',_0x3cad4f,_0x4b6214[_0xc680('0x26')]['message']);return _0x2cd697(_0x4b6214[_0xc680('0x26')]['message']);}else{logger['info'](_0xc680('0x28'),_0x3cad4f,_0xc680('0x23'));_0x2cd697(_0x4b6214[_0xc680('0x2a')]['message']);}})[_0xc680('0x2b')](function(_0x252f85){logger[_0xc680('0x26')](_0xc680('0x28'),_0x3cad4f,_0x252f85);_0x5ada10(_0x252f85);});});}function respondWithStatusCode(_0x9cbc90,_0x382e11){_0x382e11=_0x382e11||0xcc;return function(_0x5d33cd){if(_0x5d33cd){return _0x9cbc90['sendStatus'](_0x382e11);}return _0x9cbc90[_0xc680('0x2c')](_0x382e11)['end']();};}function respondWithResult(_0x6dce4b,_0x445b39){_0x445b39=_0x445b39||0xc8;return function(_0x257b1f){if(_0x257b1f){return _0x6dce4b[_0xc680('0x2c')](_0x445b39)[_0xc680('0x2d')](_0x257b1f);}};}function respondWithFilteredResult(_0x1f1196,_0x2fdbc3){return function(_0x486f0f){if(_0x486f0f){var _0xa2f928=typeof _0x2fdbc3[_0xc680('0x2e')]===_0xc680('0x2f')&&typeof _0x2fdbc3['limit']===_0xc680('0x2f');var _0x78a7a9=_0x486f0f[_0xc680('0x30')];var _0x107c81=_0xa2f928?0x0:_0x2fdbc3[_0xc680('0x2e')];var _0x5af9cf=_0xa2f928?_0x486f0f[_0xc680('0x30')]:_0x2fdbc3[_0xc680('0x2e')]+_0x2fdbc3[_0xc680('0x31')];var _0x597b0b;if(_0x5af9cf>=_0x78a7a9){_0x5af9cf=_0x78a7a9;_0x597b0b=0xc8;}else{_0x597b0b=0xce;}_0x1f1196['status'](_0x597b0b);return _0x1f1196[_0xc680('0x32')](_0xc680('0x33'),_0x107c81+'-'+_0x5af9cf+'/'+_0x78a7a9)[_0xc680('0x2d')](_0x486f0f);}return null;};}function patchUpdates(_0x1d84d2){return function(_0x46ae9a){try{jsonpatch['apply'](_0x46ae9a,_0x1d84d2,!![]);}catch(_0x2d0123){return BPromise[_0xc680('0x34')](_0x2d0123);}return _0x46ae9a['save']();};}function saveUpdates(_0x474b95,_0x5ed30c){return function(_0x40819e){if(_0x40819e){return _0x40819e['update'](_0x474b95)[_0xc680('0x22')](function(_0x20f7ff){return _0x20f7ff;});}return null;};}function removeEntity(_0x59727b,_0x46ad65){return function(_0x4457bf){if(_0x4457bf){return _0x4457bf[_0xc680('0x35')]()[_0xc680('0x22')](function(){_0x59727b['status'](0xcc)['end']();});}};}function handleEntityNotFound(_0x327ee0,_0x1eba94){return function(_0x1a9092){if(!_0x1a9092){_0x327ee0[_0xc680('0x36')](0x194);}return _0x1a9092;};}function handleError(_0x2f4cf1,_0x275247){_0x275247=_0x275247||0x1f4;return function(_0x8aff1b){logger[_0xc680('0x26')](_0x8aff1b[_0xc680('0x37')]);if(_0x8aff1b[_0xc680('0x38')]){delete _0x8aff1b[_0xc680('0x38')];}_0x2f4cf1['status'](_0x275247)['send'](_0x8aff1b);};}exports[_0xc680('0x39')]=function(_0x34b414,_0x4a4efe){var _0x3f45f5={},_0x35fa35={},_0x29aa60={'count':0x0,'rows':[]};var _0x5c8dbd=_[_0xc680('0x3a')](db['WhatsappMessage'][_0xc680('0x3b')],function(_0x4b4d45){return{'name':_0x4b4d45['fieldName'],'type':_0x4b4d45[_0xc680('0x3c')]['key']};});_0x35fa35['model']=_[_0xc680('0x3a')](_0x5c8dbd,_0xc680('0x38'));_0x35fa35[_0xc680('0x3d')]=_[_0xc680('0x3e')](_0x34b414['query']);_0x35fa35[_0xc680('0x3f')]=_[_0xc680('0x40')](_0x35fa35[_0xc680('0x41')],_0x35fa35[_0xc680('0x3d')]);_0x3f45f5['attributes']=_[_0xc680('0x40')](_0x35fa35[_0xc680('0x41')],qs[_0xc680('0x42')](_0x34b414[_0xc680('0x3d')][_0xc680('0x42')]));_0x3f45f5[_0xc680('0x43')]=_0x3f45f5[_0xc680('0x43')][_0xc680('0x44')]?_0x3f45f5[_0xc680('0x43')]:_0x35fa35[_0xc680('0x41')];if(!_0x34b414[_0xc680('0x3d')]['hasOwnProperty']('nolimit')){_0x3f45f5[_0xc680('0x31')]=qs[_0xc680('0x31')](_0x34b414['query']['limit']);_0x3f45f5[_0xc680('0x2e')]=qs[_0xc680('0x2e')](_0x34b414[_0xc680('0x3d')]['offset']);}_0x3f45f5[_0xc680('0x45')]=qs[_0xc680('0x46')](_0x34b414[_0xc680('0x3d')]['sort']);_0x3f45f5[_0xc680('0x47')]=qs[_0xc680('0x3f')](_['pick'](_0x34b414[_0xc680('0x3d')],_0x35fa35[_0xc680('0x3f')]),_0x5c8dbd);if(_0x34b414[_0xc680('0x3d')]['filter']){_0x3f45f5[_0xc680('0x47')]=_[_0xc680('0x48')](_0x3f45f5[_0xc680('0x47')],{'$or':_[_0xc680('0x3a')](_0x5c8dbd,function(_0x23b2c3){if(_0x23b2c3['type']!=='VIRTUAL'){var _0x305288={};_0x305288[_0x23b2c3[_0xc680('0x38')]]={'$like':'%'+_0x34b414[_0xc680('0x3d')][_0xc680('0x49')]+'%'};return _0x305288;}})});}_0x3f45f5=_[_0xc680('0x48')]({},_0x3f45f5,_0x34b414['options']);var _0xd1a34={'where':_0x3f45f5[_0xc680('0x47')]};return db[_0xc680('0x4a')][_0xc680('0x30')](_0xd1a34)[_0xc680('0x22')](function(_0x382cf6){_0x29aa60[_0xc680('0x30')]=_0x382cf6;if(_0x34b414[_0xc680('0x3d')][_0xc680('0x4b')]){_0x3f45f5['include']=[{'all':!![]}];}return db[_0xc680('0x4a')]['findAll'](_0x3f45f5);})[_0xc680('0x22')](function(_0x196772){_0x29aa60[_0xc680('0x4c')]=_0x196772;return _0x29aa60;})['then'](respondWithFilteredResult(_0x4a4efe,_0x3f45f5))[_0xc680('0x2b')](handleError(_0x4a4efe,null));};exports[_0xc680('0x4d')]=function(_0x33405c,_0xbe0072){var _0x2a92ea={'raw':!![],'where':{'id':_0x33405c['params']['id']}},_0x1e32bb={};_0x1e32bb['model']=_[_0xc680('0x3e')](db[_0xc680('0x4a')][_0xc680('0x3b')]);_0x1e32bb[_0xc680('0x3d')]=_[_0xc680('0x3e')](_0x33405c['query']);_0x1e32bb[_0xc680('0x3f')]=_['intersection'](_0x1e32bb[_0xc680('0x41')],_0x1e32bb[_0xc680('0x3d')]);_0x2a92ea[_0xc680('0x43')]=_[_0xc680('0x40')](_0x1e32bb[_0xc680('0x41')],qs[_0xc680('0x42')](_0x33405c['query'][_0xc680('0x42')]));_0x2a92ea[_0xc680('0x43')]=_0x2a92ea[_0xc680('0x43')][_0xc680('0x44')]?_0x2a92ea['attributes']:_0x1e32bb['model'];if(_0x33405c[_0xc680('0x3d')][_0xc680('0x4b')]){_0x2a92ea[_0xc680('0x4e')]=[{'all':!![]}];}_0x2a92ea=_[_0xc680('0x48')]({},_0x2a92ea,_0x33405c['options']);return db[_0xc680('0x4a')][_0xc680('0x4f')](_0x2a92ea)[_0xc680('0x22')](handleEntityNotFound(_0xbe0072,null))[_0xc680('0x22')](respondWithResult(_0xbe0072,null))[_0xc680('0x2b')](handleError(_0xbe0072,null));};exports[_0xc680('0x50')]=function(_0x39f095,_0x19cb91){return db[_0xc680('0x4a')][_0xc680('0x50')](_0x39f095['body'],{})[_0xc680('0x22')](respondWithResult(_0x19cb91,0xc9))[_0xc680('0x2b')](handleError(_0x19cb91,null));};exports[_0xc680('0x51')]=function(_0x307333,_0x2440b0){if(_0x307333[_0xc680('0x52')]['id']){delete _0x307333[_0xc680('0x52')]['id'];}return db[_0xc680('0x4a')][_0xc680('0x4f')]({'where':{'id':_0x307333[_0xc680('0x53')]['id']}})[_0xc680('0x22')](handleEntityNotFound(_0x2440b0,null))[_0xc680('0x22')](saveUpdates(_0x307333[_0xc680('0x52')],null))[_0xc680('0x22')](respondWithResult(_0x2440b0,null))[_0xc680('0x2b')](handleError(_0x2440b0,null));};exports[_0xc680('0x35')]=function(_0x1d3327,_0x2a4c12){return db[_0xc680('0x4a')][_0xc680('0x4f')]({'where':{'id':_0x1d3327['params']['id']}})[_0xc680('0x22')](handleEntityNotFound(_0x2a4c12,null))[_0xc680('0x22')](removeEntity(_0x2a4c12,null))[_0xc680('0x2b')](handleError(_0x2a4c12,null));};exports[_0xc680('0x54')]=function(_0x21a33c,_0x3737cd){return db[_0xc680('0x4a')][_0xc680('0x54')]()[_0xc680('0x22')](respondWithResult(_0x3737cd,null))[_0xc680('0x2b')](handleError(_0x3737cd,null));};var interaction_log=require('../../config/logger')(_0xc680('0x55'));exports[_0xc680('0x56')]=function(_0x216169,_0x173729,_0x40bc9d){var _0x58085c={'agent':{},'channel':_0xc680('0x57')};if(_0x216169[_0xc680('0x52')]['id']){delete _0x216169[_0xc680('0x52')]['id'];}_0x216169[_0xc680('0x52')][_0xc680('0x58')]=!![];_0x216169[_0xc680('0x52')][_0xc680('0x59')]=moment()[_0xc680('0x5a')](_0xc680('0x5b'));_0x216169[_0xc680('0x52')][_0xc680('0x5c')]=_0x216169[_0xc680('0x52')]['UserId']||_0x216169[_0xc680('0x5d')]['id'];_0x58085c[_0xc680('0x5e')]['id']=_0x216169[_0xc680('0x52')][_0xc680('0x5c')];return db[_0xc680('0x4a')]['find']({'where':{'id':_0x216169[_0xc680('0x53')]['id'],'UserId':null}})[_0xc680('0x22')](handleEntityNotFound(_0x173729,null))[_0xc680('0x22')](saveUpdates(_0x216169[_0xc680('0x52')],null))[_0xc680('0x22')](function(_0x1bfdac){if(_0x1bfdac){_0x58085c['message']=_0x1bfdac[_0xc680('0x5f')]({'plain':!![]});return db[_0xc680('0x60')][_0xc680('0x4f')]({'where':{'id':_0x1bfdac[_0xc680('0x61')]}});}return null;})[_0xc680('0x22')](handleEntityNotFound(_0x173729,null))[_0xc680('0x22')](function(_0x388ed5){if(_0x388ed5){return _0x388ed5[_0xc680('0x51')]({'UserId':_0x216169[_0xc680('0x52')][_0xc680('0x5c')],'read1stAt':_[_0xc680('0x62')](_0x388ed5[_0xc680('0x63')])?moment()[_0xc680('0x5a')]('YYYY-MM-DD\x20HH:mm:ss'):undefined});}return null;})[_0xc680('0x22')](function(_0xf9bed4){if(_0xf9bed4){_0x58085c[_0xc680('0x64')]=_0xf9bed4[_0xc680('0x5f')]({'plain':!![]});interaction_log[_0xc680('0x65')](_0xc680('0x66'),_0x216169[_0xc680('0x5d')]['id'],_0x216169[_0xc680('0x5d')][_0xc680('0x38')],_0x216169[_0xc680('0x5d')][_0xc680('0x67')],_0x58085c['interaction']['id'],_0x216169[_0xc680('0x52')]?JSON[_0xc680('0x68')](_0x216169[_0xc680('0x52')]):_0xc680('0x69'));return respondWithRpcPromise('AcceptMessage',_0xc680('0x6a'),_0x58085c);}return null;})[_0xc680('0x22')](function(_0x49a1ad){var _0x1fb4ae=_0xc680('0x6b')+_0x49a1ad[_0xc680('0x29')][_0xc680('0x6c')];return db['sequelize'][_0xc680('0x3d')](_0x1fb4ae,{'type':db['Sequelize'][_0xc680('0x6d')][_0xc680('0x6e')],'raw':!![]})[_0xc680('0x22')](function(_0x20a098){return _0x20a098;});})['then'](function(_0x4d6240){if(_0x4d6240){_0x58085c[_0xc680('0x29')]['contact']=_0x4d6240[0x0];if(!_0x216169[_0xc680('0x52')][_0xc680('0x5c')])return;return db[_0xc680('0x6f')][_0xc680('0x4f')]({'where':{'id':_0x216169[_0xc680('0x52')][_0xc680('0x5c')],'role':_0xc680('0x5e')},'attributes':['id','name',_0xc680('0x70'),'email','internal'],'raw':!![]});}return null;})[_0xc680('0x22')](function(_0x45ccbb){if(!_0x45ccbb)return null;_0x58085c[_0xc680('0x29')][_0xc680('0x5e')]=_0x45ccbb;return _0x58085c;})[_0xc680('0x22')](function(_0x11247a){if(_0x11247a){if(_0x216169[_0xc680('0x52')][_0xc680('0x71')]){_0x58085c['message'][_0xc680('0x72')]=util[_0xc680('0x5a')](_0xc680('0x73'),_0x216169[_0xc680('0x5d')][_0xc680('0x38')]);_0x58085c[_0xc680('0x29')]['channel']=_0x58085c[_0xc680('0x74')];_0x58085c['message'][_0xc680('0x75')]=_0x58085c[_0xc680('0x74')];_0x58085c[_0xc680('0x29')][_0xc680('0x76')]='accept';return respondWithRpcPromise(_0xc680('0x77'),'EventManager',{'event':_0xc680('0x78'),'message':_0x58085c[_0xc680('0x29')]},client9002)[_0xc680('0x22')](function(){return _0x58085c;});}return _0x58085c;}return null;})[_0xc680('0x22')](respondWithResult(_0x173729,null))['catch'](handleError(_0x173729,null));};var interaction_log=require('../../config/logger')(_0xc680('0x55'));exports[_0xc680('0x34')]=function(_0x53623e,_0x59c4ad,_0x50b06f){var _0x383284={'agent':{},'channel':_0xc680('0x57')};if(_0x53623e[_0xc680('0x52')]['id']){delete _0x53623e[_0xc680('0x52')]['id'];}_0x53623e[_0xc680('0x52')][_0xc680('0x5c')]=_0x53623e['body'][_0xc680('0x5c')]||_0x53623e[_0xc680('0x5d')]['id'];_0x383284[_0xc680('0x5e')]['id']=_0x53623e[_0xc680('0x52')]['UserId'];return db['WhatsappMessage'][_0xc680('0x4f')]({'where':{'id':_0x53623e[_0xc680('0x53')]['id'],'UserId':null}})[_0xc680('0x22')](handleEntityNotFound(_0x59c4ad,null))['then'](function(_0x1533c5){if(_0x1533c5){_0x383284[_0xc680('0x29')]=_0x1533c5[_0xc680('0x5f')]({'plain':!![]});return db[_0xc680('0x60')][_0xc680('0x4f')]({'where':{'id':_0x1533c5['WhatsappInteractionId']}});}return null;})[_0xc680('0x22')](handleEntityNotFound(_0x59c4ad,null))[_0xc680('0x22')](function(_0xb4b5ef){if(_0xb4b5ef){_0x383284['interaction']=_0xb4b5ef['get']({'plain':!![]});interaction_log[_0xc680('0x65')]('[WHATSAPPMESSAGE:REJECT]\x20id=%s\x20name=%s\x20role=%s\x20interaction=%s\x20body=%s',_0x53623e[_0xc680('0x5d')]['id'],_0x53623e[_0xc680('0x5d')][_0xc680('0x38')],_0x53623e['user'][_0xc680('0x67')],_0x383284[_0xc680('0x64')]['id'],_0x53623e[_0xc680('0x52')]?JSON['stringify'](_0x53623e[_0xc680('0x52')]):_0xc680('0x69'));return respondWithRpcPromise(_0xc680('0x79'),_0xc680('0x7a'),_0x383284);}return null;})[_0xc680('0x22')](function(_0x3e1406){var _0x49b0f6=_0xc680('0x6b')+_0x3e1406[_0xc680('0x29')][_0xc680('0x6c')];return db[_0xc680('0x7b')]['query'](_0x49b0f6,{'type':db[_0xc680('0x7c')][_0xc680('0x6d')][_0xc680('0x6e')],'raw':!![]})[_0xc680('0x22')](function(_0x21bd76){return _0x21bd76;});})[_0xc680('0x22')](function(_0x54c52f){if(_0x54c52f){_0x383284['message'][_0xc680('0x7d')]=_0x54c52f[0x0];if(!_0x53623e[_0xc680('0x52')][_0xc680('0x5c')])return;return db[_0xc680('0x6f')][_0xc680('0x4f')]({'where':{'id':_0x53623e[_0xc680('0x52')][_0xc680('0x5c')],'role':'agent'},'attributes':['id',_0xc680('0x38'),_0xc680('0x70'),_0xc680('0x7e'),_0xc680('0x7f')],'raw':!![]});}return null;})['then'](function(_0x1255fd){if(!_0x1255fd)return null;_0x383284[_0xc680('0x29')][_0xc680('0x5e')]=_0x1255fd;return _0x383284;})['then'](function(_0x5bc839){if(_0x5bc839){_0x5bc839[_0xc680('0x29')][_0xc680('0x72')]=util[_0xc680('0x5a')]('SIP/%s',_0x53623e[_0xc680('0x5d')][_0xc680('0x38')]);_0x5bc839[_0xc680('0x29')]['channel']=_0x383284['channel'];_0x5bc839[_0xc680('0x29')][_0xc680('0x75')]=_0x383284['channel'];_0x5bc839[_0xc680('0x29')][_0xc680('0x76')]=_0xc680('0x34');respondWithRpcPromise(_0xc680('0x77'),_0xc680('0x77'),{'event':'rejectmessage','message':_0x5bc839[_0xc680('0x29')]},client9002);return _0x383284;}return null;})[_0xc680('0x22')](respondWithResult(_0x59c4ad,null))[_0xc680('0x2b')](handleError(_0x59c4ad,null));};exports[_0xc680('0x2c')]=function(_0x35745b,_0x4b58a7,_0x98418e){if(_0x35745b['body']['id']){delete _0x35745b['body']['id'];}var _0x24aea1;return db[_0xc680('0x4a')][_0xc680('0x4f')]({'where':{'id':_0x35745b[_0xc680('0x53')]['id']}})[_0xc680('0x22')](handleEntityNotFound(_0x4b58a7,null))[_0xc680('0x22')](function(_0x4f98a6){if(_0x4f98a6){_0x24aea1=_0x4f98a6;return db[_0xc680('0x80')][_0xc680('0x4f')]({'where':{'id':_0x4f98a6[_0xc680('0x81')]}});}})['then'](handleEntityNotFound(_0x4b58a7,null))[_0xc680('0x22')](function(_0x112c0e){if(_0x112c0e){logger[_0xc680('0x24')](_0xc680('0x82'),_0xc680('0x2c'),'received\x20delivery\x20report\x20from',_0x112c0e[_0xc680('0x3c')],util[_0xc680('0x83')](_0x35745b[_0xc680('0x52')],{'showHidden':![],'depth':null}));switch(_0x112c0e[_0xc680('0x3c')]){case _0xc680('0x84'):if(_0x35745b['body'][_0xc680('0x85')]&&_0x35745b['body'][_0xc680('0x85')]===_0x24aea1[_0xc680('0x86')]&&_0x35745b[_0xc680('0x52')][_0xc680('0x87')]&&_0x35745b['body'][_0xc680('0x87')]===_0xc680('0x58')){return _0x24aea1[_0xc680('0x51')]({'read':!![]});}else{logger[_0xc680('0x26')](_0xc680('0x88'),_0xc680('0x2c'),'twilio',util[_0xc680('0x83')](_0x35745b[_0xc680('0x52')],{'showHidden':![],'depth':null}));}break;}return _0x24aea1;}})[_0xc680('0x22')](respondWithResult(_0x4b58a7,null))[_0xc680('0x2b')](handleError(_0x4b58a7,null));};
\ No newline at end of file