Built motion from commit 753c950e.|2.5.42
[motion2.git] / server / api / whatsappMessage / whatsappMessage.controller.js
index d779aa0..d4bed56 100644 (file)
@@ -15,4 +15,4 @@
 // * treaties. The SOFTWARE PRODUCT is licensed, not sold.                        *
 // *                                                                       *
 // *************************************************************************
-var _0x5f9b=['rejectMessage','SIP/%s','event','rejectmessage','WhatsappAccount','WhatsappAccountId','WhatsppMessage,\x20%s,\x20%s,\x20%s','received\x20delivery\x20report\x20from','inspect','twilio','MessageSid','messageId','MessageStatus','WhatsappAccount,\x20%s,\x20%s,\x20%s','html-pdf','eml-format','rimraf','zip-dir','fast-json-patch','moment','mustache','path','sox','to-csv','ejs','lodash','squel','crypto','querystring','papaparse','ioredis','../../components/parsers/qs','../../components/parsers/advancedSearch','../../config/license/hardware','../../config/logger','api','../../config/environment','../../mysqldb','redis','defaults','localhost','socket.io-emitter','./whatsappMessage.socket','register','jayson/promise','client','http','test','Sequelize','ValidationError','The\x20password\x20must\x20be\x20at\x20least\x208\x20characters\x20long\x20and\x20have\x201\x20lowercase\x20character,\x201\x20uppercase\x20character,\x201\x20number\x20and\x201\x20special\x20character\x20~!@#$%^&-_=+[{]}.','request','then','info','WhatsappMessage,\x20%s,\x20%s','debug','WhatsappMessage,\x20%s,\x20%s,\x20%s','request\x20sent','stringify','error','code','message','result','catch','sendStatus','end','status','json','count','offset','apply','reject','save','update','name','index','map','WhatsappMessage','type','model','query','attributes','fields','length','hasOwnProperty','nolimit','limit','sort','filters','pick','filter','where','merge','includeAll','include','findAll','rows','params','keys','intersection','options','create','body','find','destroy','whatsapp-interactions','accept','whatsapp','read','format','YYYY-MM-DD\x20HH:mm:ss','UserId','user','CmContact','Contact','get','WhatsappInteractionId','isNil','read1stAt','interaction','AcceptMessage','acceptMessage','interface','channel','EventManager','acceptmessage','agent','WhatsappInteraction','[WHATSAPPMESSAGE:REJECT]\x20id=%s\x20name=%s\x20role=%s\x20interaction=%s\x20body=%s','role'];(function(_0xff6ae1,_0x5c13e2){var _0x389fa2=function(_0x46f4cc){while(--_0x46f4cc){_0xff6ae1['push'](_0xff6ae1['shift']());}};_0x389fa2(++_0x5c13e2);}(_0x5f9b,0x90));var _0xb5f9=function(_0x1bcbf7,_0x31bf2a){_0x1bcbf7=_0x1bcbf7-0x0;var _0x4aeb5b=_0x5f9b[_0x1bcbf7];return _0x4aeb5b;};'use strict';var pdf=require(_0xb5f9('0x0'));var emlformat=require(_0xb5f9('0x1'));var rimraf=require(_0xb5f9('0x2'));var zipdir=require(_0xb5f9('0x3'));var jsonpatch=require(_0xb5f9('0x4'));var rp=require('request-promise');var moment=require(_0xb5f9('0x5'));var BPromise=require('bluebird');var Mustache=require(_0xb5f9('0x6'));var util=require('util');var path=require(_0xb5f9('0x7'));var sox=require(_0xb5f9('0x8'));var csv=require(_0xb5f9('0x9'));var ejs=require(_0xb5f9('0xa'));var fs=require('fs');var _=require(_0xb5f9('0xb'));var squel=require(_0xb5f9('0xc'));var crypto=require(_0xb5f9('0xd'));var jsforce=require('jsforce');var deskjs=require('desk.js');var toCsv=require('to-csv');var querystring=require(_0xb5f9('0xe'));var Papa=require(_0xb5f9('0xf'));var Redis=require(_0xb5f9('0x10'));var authService=require('../../components/auth/service');var qs=require(_0xb5f9('0x11'));var as=require(_0xb5f9('0x12'));var hardwareService=require(_0xb5f9('0x13'));var logger=require(_0xb5f9('0x14'))(_0xb5f9('0x15'));var utils=require('../../config/utils');var config=require(_0xb5f9('0x16'));var db=require(_0xb5f9('0x17'))['db'];config[_0xb5f9('0x18')]=_[_0xb5f9('0x19')](config[_0xb5f9('0x18')],{'host':_0xb5f9('0x1a'),'port':0x18eb});var socket=require(_0xb5f9('0x1b'))(new Redis(config[_0xb5f9('0x18')]));require(_0xb5f9('0x1c'))[_0xb5f9('0x1d')](socket);var jayson=require(_0xb5f9('0x1e'));var client=jayson[_0xb5f9('0x1f')]['http']({'port':0x232c});var client9002=jayson[_0xb5f9('0x1f')][_0xb5f9('0x20')]({'port':0x232a});function checkPasswordPattern(_0x2837de,_0x21f95d,_0x527777){if(_0x527777){var _0x4eda61=new RegExp(/(?=.*[a-z])(?=.*[A-Z])(?=.*[0-9])(?=.*[?!@#\$%\^&\*~\-_=+[{\]\}])(?=.{8,})/);if(_0x4eda61[_0xb5f9('0x21')](_0x21f95d)){return _0x2837de;}else{throw new db[(_0xb5f9('0x22'))][(_0xb5f9('0x23'))](_0xb5f9('0x24'));}}else{return _0x2837de;}}function respondWithRpcPromise(_0x725d94,_0x1df27a,_0x5d6680,_0x31fb28){return new BPromise(function(_0x31e876,_0x371adc){var _0x3ea256=_0x31fb28||client;return _0x3ea256[_0xb5f9('0x25')](_0x725d94,_0x5d6680)[_0xb5f9('0x26')](function(_0x40a0db){logger[_0xb5f9('0x27')](_0xb5f9('0x28'),_0x1df27a,'request\x20sent');logger[_0xb5f9('0x29')](_0xb5f9('0x2a'),_0x1df27a,_0xb5f9('0x2b'),JSON[_0xb5f9('0x2c')](_0x40a0db));if(_0x40a0db['error']){if(_0x40a0db[_0xb5f9('0x2d')][_0xb5f9('0x2e')]===0x1f4){logger[_0xb5f9('0x2d')](_0xb5f9('0x28'),_0x1df27a,_0x40a0db[_0xb5f9('0x2d')][_0xb5f9('0x2f')]);return _0x371adc(_0x40a0db['error']['message']);}logger[_0xb5f9('0x2d')]('WhatsappMessage,\x20%s,\x20%s',_0x1df27a,_0x40a0db[_0xb5f9('0x2d')][_0xb5f9('0x2f')]);return _0x31e876(_0x40a0db[_0xb5f9('0x2d')][_0xb5f9('0x2f')]);}else{logger['info'](_0xb5f9('0x28'),_0x1df27a,_0xb5f9('0x2b'));_0x31e876(_0x40a0db[_0xb5f9('0x30')][_0xb5f9('0x2f')]);}})[_0xb5f9('0x31')](function(_0x207032){logger['error'](_0xb5f9('0x28'),_0x1df27a,_0x207032);_0x371adc(_0x207032);});});}function respondWithStatusCode(_0x2b6b03,_0x22a8a0){_0x22a8a0=_0x22a8a0||0xcc;return function(_0x3e8a0b){if(_0x3e8a0b){return _0x2b6b03[_0xb5f9('0x32')](_0x22a8a0);}return _0x2b6b03['status'](_0x22a8a0)[_0xb5f9('0x33')]();};}function respondWithResult(_0x2256a8,_0x480c03){_0x480c03=_0x480c03||0xc8;return function(_0x21904f){if(_0x21904f){return _0x2256a8[_0xb5f9('0x34')](_0x480c03)[_0xb5f9('0x35')](_0x21904f);}};}function respondWithFilteredResult(_0x39f353,_0x49b717){return function(_0x1efceb){if(_0x1efceb){var _0x462a48=_0x1efceb[_0xb5f9('0x36')],_0x5a38b0=_0x49b717[_0xb5f9('0x37')],_0x3b8c2f=_0x49b717['offset']+_0x49b717['limit'],_0x343cf5;if(_0x3b8c2f>=_0x462a48){_0x3b8c2f=_0x462a48;_0x343cf5=0xc8;}else{_0x343cf5=0xce;}_0x39f353['status'](_0x343cf5);return _0x39f353['set']('Content-Range',_0x5a38b0+'-'+_0x3b8c2f+'/'+_0x462a48)[_0xb5f9('0x35')](_0x1efceb);}return null;};}function patchUpdates(_0x79f2a3){return function(_0x448700){try{jsonpatch[_0xb5f9('0x38')](_0x448700,_0x79f2a3,!![]);}catch(_0x4416f5){return BPromise[_0xb5f9('0x39')](_0x4416f5);}return _0x448700[_0xb5f9('0x3a')]();};}function saveUpdates(_0x1a17d8,_0x47fbe9){return function(_0x20238b){if(_0x20238b){return _0x20238b[_0xb5f9('0x3b')](_0x1a17d8)['then'](function(_0x5d305b){return _0x5d305b;});}return null;};}function removeEntity(_0xf60053,_0x74751d){return function(_0x4a8c2a){if(_0x4a8c2a){return _0x4a8c2a['destroy']()[_0xb5f9('0x26')](function(){_0xf60053['status'](0xcc)[_0xb5f9('0x33')]();});}};}function handleEntityNotFound(_0x8e5b12,_0x1bfa4d){return function(_0x4fb621){if(!_0x4fb621){_0x8e5b12[_0xb5f9('0x32')](0x194);}return _0x4fb621;};}function handleError(_0x4148ad,_0x2adc09){_0x2adc09=_0x2adc09||0x1f4;return function(_0x4057ae){logger['error'](_0x4057ae['stack']);if(_0x4057ae[_0xb5f9('0x3c')]){delete _0x4057ae['name'];}_0x4148ad[_0xb5f9('0x34')](_0x2adc09)['send'](_0x4057ae);};}exports[_0xb5f9('0x3d')]=function(_0x1b9ae5,_0x5050d5){var _0x365207={},_0xeb737f={},_0x34929b={'count':0x0,'rows':[]};var _0x41516f=_[_0xb5f9('0x3e')](db[_0xb5f9('0x3f')]['rawAttributes'],function(_0x801cd){return{'name':_0x801cd['fieldName'],'type':_0x801cd[_0xb5f9('0x40')]['key']};});_0xeb737f[_0xb5f9('0x41')]=_['map'](_0x41516f,_0xb5f9('0x3c'));_0xeb737f[_0xb5f9('0x42')]=_['keys'](_0x1b9ae5['query']);_0xeb737f['filters']=_['intersection'](_0xeb737f[_0xb5f9('0x41')],_0xeb737f['query']);_0x365207[_0xb5f9('0x43')]=_['intersection'](_0xeb737f['model'],qs[_0xb5f9('0x44')](_0x1b9ae5['query']['fields']));_0x365207['attributes']=_0x365207[_0xb5f9('0x43')][_0xb5f9('0x45')]?_0x365207[_0xb5f9('0x43')]:_0xeb737f[_0xb5f9('0x41')];if(!_0x1b9ae5[_0xb5f9('0x42')][_0xb5f9('0x46')](_0xb5f9('0x47'))){_0x365207[_0xb5f9('0x48')]=qs[_0xb5f9('0x48')](_0x1b9ae5[_0xb5f9('0x42')][_0xb5f9('0x48')]);_0x365207[_0xb5f9('0x37')]=qs[_0xb5f9('0x37')](_0x1b9ae5[_0xb5f9('0x42')][_0xb5f9('0x37')]);}_0x365207['order']=qs[_0xb5f9('0x49')](_0x1b9ae5[_0xb5f9('0x42')][_0xb5f9('0x49')]);_0x365207['where']=qs[_0xb5f9('0x4a')](_[_0xb5f9('0x4b')](_0x1b9ae5['query'],_0xeb737f['filters']),_0x41516f);if(_0x1b9ae5[_0xb5f9('0x42')][_0xb5f9('0x4c')]){_0x365207[_0xb5f9('0x4d')]=_[_0xb5f9('0x4e')](_0x365207[_0xb5f9('0x4d')],{'$or':_['map'](_0x41516f,function(_0x4e233d){if(_0x4e233d[_0xb5f9('0x40')]!=='VIRTUAL'){var _0x10e7e3={};_0x10e7e3[_0x4e233d[_0xb5f9('0x3c')]]={'$like':'%'+_0x1b9ae5['query'][_0xb5f9('0x4c')]+'%'};return _0x10e7e3;}})});}_0x365207=_['merge']({},_0x365207,_0x1b9ae5['options']);var _0x19ceed={'where':_0x365207[_0xb5f9('0x4d')]};return db[_0xb5f9('0x3f')][_0xb5f9('0x36')](_0x19ceed)['then'](function(_0x5b6a6c){_0x34929b['count']=_0x5b6a6c;if(_0x1b9ae5[_0xb5f9('0x42')][_0xb5f9('0x4f')]){_0x365207[_0xb5f9('0x50')]=[{'all':!![]}];}return db[_0xb5f9('0x3f')][_0xb5f9('0x51')](_0x365207);})[_0xb5f9('0x26')](function(_0x676859){_0x34929b[_0xb5f9('0x52')]=_0x676859;return _0x34929b;})[_0xb5f9('0x26')](respondWithFilteredResult(_0x5050d5,_0x365207))[_0xb5f9('0x31')](handleError(_0x5050d5,null));};exports['show']=function(_0x2aecc9,_0x19265c){var _0x48bd3d={'raw':!![],'where':{'id':_0x2aecc9[_0xb5f9('0x53')]['id']}},_0x4d089d={};_0x4d089d[_0xb5f9('0x41')]=_[_0xb5f9('0x54')](db['WhatsappMessage']['rawAttributes']);_0x4d089d[_0xb5f9('0x42')]=_['keys'](_0x2aecc9[_0xb5f9('0x42')]);_0x4d089d[_0xb5f9('0x4a')]=_[_0xb5f9('0x55')](_0x4d089d[_0xb5f9('0x41')],_0x4d089d[_0xb5f9('0x42')]);_0x48bd3d['attributes']=_[_0xb5f9('0x55')](_0x4d089d[_0xb5f9('0x41')],qs[_0xb5f9('0x44')](_0x2aecc9[_0xb5f9('0x42')][_0xb5f9('0x44')]));_0x48bd3d[_0xb5f9('0x43')]=_0x48bd3d['attributes'][_0xb5f9('0x45')]?_0x48bd3d['attributes']:_0x4d089d['model'];if(_0x2aecc9[_0xb5f9('0x42')][_0xb5f9('0x4f')]){_0x48bd3d[_0xb5f9('0x50')]=[{'all':!![]}];}_0x48bd3d=_['merge']({},_0x48bd3d,_0x2aecc9[_0xb5f9('0x56')]);return db[_0xb5f9('0x3f')]['find'](_0x48bd3d)[_0xb5f9('0x26')](handleEntityNotFound(_0x19265c,null))[_0xb5f9('0x26')](respondWithResult(_0x19265c,null))[_0xb5f9('0x31')](handleError(_0x19265c,null));};exports[_0xb5f9('0x57')]=function(_0x2addbf,_0x363fde){return db[_0xb5f9('0x3f')][_0xb5f9('0x57')](_0x2addbf[_0xb5f9('0x58')],{})['then'](respondWithResult(_0x363fde,0xc9))[_0xb5f9('0x31')](handleError(_0x363fde,null));};exports[_0xb5f9('0x3b')]=function(_0x18b29e,_0x8dc985){if(_0x18b29e['body']['id']){delete _0x18b29e[_0xb5f9('0x58')]['id'];}return db[_0xb5f9('0x3f')][_0xb5f9('0x59')]({'where':{'id':_0x18b29e[_0xb5f9('0x53')]['id']}})[_0xb5f9('0x26')](handleEntityNotFound(_0x8dc985,null))[_0xb5f9('0x26')](saveUpdates(_0x18b29e['body'],null))['then'](respondWithResult(_0x8dc985,null))[_0xb5f9('0x31')](handleError(_0x8dc985,null));};exports[_0xb5f9('0x5a')]=function(_0x2867c4,_0x346aee){return db[_0xb5f9('0x3f')][_0xb5f9('0x59')]({'where':{'id':_0x2867c4[_0xb5f9('0x53')]['id']}})[_0xb5f9('0x26')](handleEntityNotFound(_0x346aee,null))[_0xb5f9('0x26')](removeEntity(_0x346aee,null))['catch'](handleError(_0x346aee,null));};exports['describe']=function(_0x4eb6a0,_0x48c207){return db[_0xb5f9('0x3f')]['describe']()[_0xb5f9('0x26')](respondWithResult(_0x48c207,null))[_0xb5f9('0x31')](handleError(_0x48c207,null));};var interaction_log=require('../../config/logger')(_0xb5f9('0x5b'));exports[_0xb5f9('0x5c')]=function(_0x47cdba,_0x222f36,_0x1c592){var _0xdb0f7c={'channel':_0xb5f9('0x5d')};if(_0x47cdba[_0xb5f9('0x58')]['id']){delete _0x47cdba[_0xb5f9('0x58')]['id'];}_0x47cdba['body'][_0xb5f9('0x5e')]=!![];_0x47cdba['body']['readAt']=moment()[_0xb5f9('0x5f')](_0xb5f9('0x60'));_0x47cdba[_0xb5f9('0x58')][_0xb5f9('0x61')]=_0x47cdba[_0xb5f9('0x58')][_0xb5f9('0x61')]||_0x47cdba[_0xb5f9('0x62')]['id'];return db[_0xb5f9('0x3f')][_0xb5f9('0x59')]({'where':{'id':_0x47cdba[_0xb5f9('0x53')]['id'],'UserId':null},'include':[{'model':db[_0xb5f9('0x63')],'as':_0xb5f9('0x64')}]})[_0xb5f9('0x26')](handleEntityNotFound(_0x222f36,null))['then'](saveUpdates(_0x47cdba[_0xb5f9('0x58')],null))[_0xb5f9('0x26')](function(_0x16d934){if(_0x16d934){_0xdb0f7c[_0xb5f9('0x2f')]=_0x16d934[_0xb5f9('0x65')]({'plain':!![]});return db['WhatsappInteraction'][_0xb5f9('0x59')]({'where':{'id':_0x16d934[_0xb5f9('0x66')]}});}return null;})[_0xb5f9('0x26')](handleEntityNotFound(_0x222f36,null))[_0xb5f9('0x26')](function(_0x374c2a){if(_0x374c2a){return _0x374c2a[_0xb5f9('0x3b')]({'UserId':_0x47cdba['body'][_0xb5f9('0x61')],'read1stAt':_[_0xb5f9('0x67')](_0x374c2a[_0xb5f9('0x68')])?moment()['format'](_0xb5f9('0x60')):undefined});}return null;})[_0xb5f9('0x26')](function(_0x1f631c){if(_0x1f631c){_0xdb0f7c[_0xb5f9('0x69')]=_0x1f631c['get']({'plain':!![]});interaction_log['info']('[WHATSAPPMESSAGE:ACCEPT]\x20id=%s\x20name=%s\x20role=%s\x20interaction=%s\x20body=%s',_0x47cdba[_0xb5f9('0x62')]['id'],_0x47cdba[_0xb5f9('0x62')][_0xb5f9('0x3c')],_0x47cdba[_0xb5f9('0x62')]['role'],_0xdb0f7c['interaction']['id'],_0x47cdba[_0xb5f9('0x58')]?JSON['stringify'](_0x47cdba[_0xb5f9('0x58')]):'null');return respondWithRpcPromise(_0xb5f9('0x6a'),_0xb5f9('0x6b'),_0xdb0f7c);}return null;})[_0xb5f9('0x26')](function(_0x2b2d54){if(_0x2b2d54){if(_0x47cdba['body']['manual']){_0xdb0f7c[_0xb5f9('0x2f')][_0xb5f9('0x6c')]=util['format']('SIP/%s',_0x47cdba['user']['name']);_0xdb0f7c[_0xb5f9('0x2f')][_0xb5f9('0x6d')]=_0xdb0f7c['channel'];_0xdb0f7c[_0xb5f9('0x2f')]['event']=_0xb5f9('0x5c');return respondWithRpcPromise(_0xb5f9('0x6e'),_0xb5f9('0x6e'),{'event':_0xb5f9('0x6f'),'message':_0xdb0f7c[_0xb5f9('0x2f')]},client9002)[_0xb5f9('0x26')](function(){return _0xdb0f7c;});}return _0xdb0f7c;}return null;})[_0xb5f9('0x26')](respondWithResult(_0x222f36,null))[_0xb5f9('0x31')](handleError(_0x222f36,null));};var interaction_log=require(_0xb5f9('0x14'))('whatsapp-interactions');exports[_0xb5f9('0x39')]=function(_0x351363,_0x4090cc,_0x10a8c4){var _0x965836={'agent':{},'channel':_0xb5f9('0x5d')};if(_0x351363[_0xb5f9('0x58')]['id']){delete _0x351363[_0xb5f9('0x58')]['id'];}_0x351363[_0xb5f9('0x58')][_0xb5f9('0x61')]=_0x351363[_0xb5f9('0x58')][_0xb5f9('0x61')]||_0x351363[_0xb5f9('0x62')]['id'];_0x965836[_0xb5f9('0x70')]['id']=_0x351363[_0xb5f9('0x58')]['UserId'];return db[_0xb5f9('0x3f')][_0xb5f9('0x59')]({'where':{'id':_0x351363['params']['id'],'UserId':null}})[_0xb5f9('0x26')](handleEntityNotFound(_0x4090cc,null))['then'](function(_0x2fe538){if(_0x2fe538){_0x965836[_0xb5f9('0x2f')]=_0x2fe538[_0xb5f9('0x65')]({'plain':!![]});return db[_0xb5f9('0x71')][_0xb5f9('0x59')]({'where':{'id':_0x2fe538['WhatsappInteractionId']}});}return null;})[_0xb5f9('0x26')](handleEntityNotFound(_0x4090cc,null))['then'](function(_0x54487a){if(_0x54487a){_0x965836['interaction']=_0x54487a['get']({'plain':!![]});interaction_log[_0xb5f9('0x27')](_0xb5f9('0x72'),_0x351363['user']['id'],_0x351363[_0xb5f9('0x62')][_0xb5f9('0x3c')],_0x351363['user'][_0xb5f9('0x73')],_0x965836[_0xb5f9('0x69')]['id'],_0x351363['body']?JSON[_0xb5f9('0x2c')](_0x351363[_0xb5f9('0x58')]):'null');return respondWithRpcPromise('RejectMessage',_0xb5f9('0x74'),_0x965836);}return null;})[_0xb5f9('0x26')](function(_0x5e614d){if(_0x5e614d){_0x5e614d[_0xb5f9('0x2f')][_0xb5f9('0x6c')]=util['format'](_0xb5f9('0x75'),_0x351363[_0xb5f9('0x62')][_0xb5f9('0x3c')]);_0x5e614d['message'][_0xb5f9('0x6d')]=_0x965836[_0xb5f9('0x6d')];_0x5e614d[_0xb5f9('0x2f')][_0xb5f9('0x76')]='reject';respondWithRpcPromise(_0xb5f9('0x6e'),_0xb5f9('0x6e'),{'event':_0xb5f9('0x77'),'message':_0x5e614d[_0xb5f9('0x2f')]},client9002);return _0x965836;}return null;})['then'](respondWithResult(_0x4090cc,null))[_0xb5f9('0x31')](handleError(_0x4090cc,null));};exports[_0xb5f9('0x34')]=function(_0x33e24f,_0x29e2ef,_0x6f8151){if(_0x33e24f[_0xb5f9('0x58')]['id']){delete _0x33e24f[_0xb5f9('0x58')]['id'];}var _0x1ef1e0;return db[_0xb5f9('0x3f')][_0xb5f9('0x59')]({'where':{'id':_0x33e24f[_0xb5f9('0x53')]['id']}})[_0xb5f9('0x26')](handleEntityNotFound(_0x29e2ef,null))[_0xb5f9('0x26')](function(_0x276b67){if(_0x276b67){_0x1ef1e0=_0x276b67;return db[_0xb5f9('0x78')]['find']({'where':{'id':_0x276b67[_0xb5f9('0x79')]}});}})['then'](handleEntityNotFound(_0x29e2ef,null))['then'](function(_0x2411dd){if(_0x2411dd){logger[_0xb5f9('0x29')](_0xb5f9('0x7a'),_0xb5f9('0x34'),_0xb5f9('0x7b'),_0x2411dd[_0xb5f9('0x40')],util[_0xb5f9('0x7c')](_0x33e24f['body'],{'showHidden':![],'depth':null}));switch(_0x2411dd[_0xb5f9('0x40')]){case _0xb5f9('0x7d'):if(_0x33e24f['body'][_0xb5f9('0x7e')]&&_0x33e24f[_0xb5f9('0x58')]['MessageSid']===_0x1ef1e0[_0xb5f9('0x7f')]&&_0x33e24f[_0xb5f9('0x58')][_0xb5f9('0x80')]&&_0x33e24f[_0xb5f9('0x58')][_0xb5f9('0x80')]==='read'){return _0x1ef1e0[_0xb5f9('0x3b')]({'read':!![]});}else{logger[_0xb5f9('0x2d')](_0xb5f9('0x81'),_0xb5f9('0x34'),_0xb5f9('0x7d'),util[_0xb5f9('0x7c')](_0x33e24f['body'],{'showHidden':![],'depth':null}));}break;}return _0x1ef1e0;}})[_0xb5f9('0x26')](respondWithResult(_0x29e2ef,null))['catch'](handleError(_0x29e2ef,null));};
\ No newline at end of file
+var _0x791d=['./whatsappMessage.socket','register','jayson/promise','client','http','request','then','info','request\x20sent','debug','WhatsappMessage,\x20%s,\x20%s,\x20%s','error','code','WhatsappMessage,\x20%s,\x20%s','message','result','catch','sendStatus','end','status','json','offset','limit','count','set','apply','reject','destroy','name','index','map','WhatsappMessage','rawAttributes','fieldName','type','query','keys','intersection','model','attributes','fields','order','sort','where','filters','filter','merge','options','includeAll','include','findAll','rows','show','length','find','create','body','update','params','describe','whatsapp-interactions','accept','whatsapp','read','readAt','format','UserId','user','get','WhatsappInteraction','WhatsappInteractionId','read1stAt','role','interaction','stringify','null','AcceptMessage','acceptMessage','SELECT\x20*\x20FROM\x20cm_contacts\x20WHERE\x20id\x20=\x20','sequelize','Sequelize','QueryTypes','contact','User','agent','fullname','email','internal','manual','interface','SIP/%s','channel','motionChannel','event','EventManager','[WHATSAPPMESSAGE:REJECT]\x20id=%s\x20name=%s\x20role=%s\x20interaction=%s\x20body=%s','RejectMessage','rejectMessage','ContactId','SELECT','rejectmessage','WhatsappAccount','WhatsppMessage,\x20%s,\x20%s,\x20%s','received\x20delivery\x20report\x20from','twilio','MessageSid','messageId','WhatsappAccount,\x20%s,\x20%s,\x20%s','inspect','eml-format','zip-dir','fast-json-patch','request-promise','moment','bluebird','mustache','util','path','sox','ejs','fs-extra','lodash','crypto','jsforce','desk.js','to-csv','querystring','ioredis','../../components/auth/service','../../components/parsers/qs','../../config/license/hardware','api','../../config/utils','../../config/environment','../../mysqldb','redis','localhost','socket.io-emitter'];(function(_0x1ddea1,_0x4d4d1c){var _0x23f12f=function(_0x4f7296){while(--_0x4f7296){_0x1ddea1['push'](_0x1ddea1['shift']());}};_0x23f12f(++_0x4d4d1c);}(_0x791d,0x181));var _0xd791=function(_0x41f9c4,_0x100f97){_0x41f9c4=_0x41f9c4-0x0;var _0x4435c5=_0x791d[_0x41f9c4];return _0x4435c5;};'use strict';var emlformat=require(_0xd791('0x0'));var rimraf=require('rimraf');var zipdir=require(_0xd791('0x1'));var jsonpatch=require(_0xd791('0x2'));var rp=require(_0xd791('0x3'));var moment=require(_0xd791('0x4'));var BPromise=require(_0xd791('0x5'));var Mustache=require(_0xd791('0x6'));var util=require(_0xd791('0x7'));var path=require(_0xd791('0x8'));var sox=require(_0xd791('0x9'));var csv=require('to-csv');var ejs=require(_0xd791('0xa'));var fs=require('fs');var fs_extra=require(_0xd791('0xb'));var _=require(_0xd791('0xc'));var squel=require('squel');var crypto=require(_0xd791('0xd'));var jsforce=require(_0xd791('0xe'));var deskjs=require(_0xd791('0xf'));var toCsv=require(_0xd791('0x10'));var querystring=require(_0xd791('0x11'));var Papa=require('papaparse');var Redis=require(_0xd791('0x12'));var authService=require(_0xd791('0x13'));var qs=require(_0xd791('0x14'));var as=require('../../components/parsers/advancedSearch');var hardwareService=require(_0xd791('0x15'));var logger=require('../../config/logger')(_0xd791('0x16'));var utils=require(_0xd791('0x17'));var config=require(_0xd791('0x18'));var licenseUtil=require('../../config/license/util');var db=require(_0xd791('0x19'))['db'];config[_0xd791('0x1a')]=_['defaults'](config[_0xd791('0x1a')],{'host':_0xd791('0x1b'),'port':0x18eb});var socket=require(_0xd791('0x1c'))(new Redis(config[_0xd791('0x1a')]));require(_0xd791('0x1d'))[_0xd791('0x1e')](socket);var jayson=require(_0xd791('0x1f'));var client=jayson[_0xd791('0x20')][_0xd791('0x21')]({'port':0x232c});var client9002=jayson[_0xd791('0x20')][_0xd791('0x21')]({'port':0x232a});function respondWithRpcPromise(_0x582df2,_0x529c78,_0x4c1c15,_0x3db948){return new BPromise(function(_0x1947bc,_0x11f080){var _0x4c4034=_0x3db948||client;return _0x4c4034[_0xd791('0x22')](_0x582df2,_0x4c1c15)[_0xd791('0x23')](function(_0x122144){logger[_0xd791('0x24')]('WhatsappMessage,\x20%s,\x20%s',_0x529c78,_0xd791('0x25'));logger[_0xd791('0x26')](_0xd791('0x27'),_0x529c78,_0xd791('0x25'),JSON['stringify'](_0x122144));if(_0x122144['error']){if(_0x122144[_0xd791('0x28')][_0xd791('0x29')]===0x1f4){logger['error'](_0xd791('0x2a'),_0x529c78,_0x122144[_0xd791('0x28')][_0xd791('0x2b')]);return _0x11f080(_0x122144[_0xd791('0x28')][_0xd791('0x2b')]);}logger['error'](_0xd791('0x2a'),_0x529c78,_0x122144['error'][_0xd791('0x2b')]);return _0x1947bc(_0x122144['error'][_0xd791('0x2b')]);}else{logger[_0xd791('0x24')](_0xd791('0x2a'),_0x529c78,_0xd791('0x25'));_0x1947bc(_0x122144[_0xd791('0x2c')][_0xd791('0x2b')]);}})[_0xd791('0x2d')](function(_0x38d0b7){logger['error'](_0xd791('0x2a'),_0x529c78,_0x38d0b7);_0x11f080(_0x38d0b7);});});}function respondWithStatusCode(_0x217c45,_0x2fa758){_0x2fa758=_0x2fa758||0xcc;return function(_0x208b85){if(_0x208b85){return _0x217c45[_0xd791('0x2e')](_0x2fa758);}return _0x217c45['status'](_0x2fa758)[_0xd791('0x2f')]();};}function respondWithResult(_0x175b05,_0x51189e){_0x51189e=_0x51189e||0xc8;return function(_0x270a58){if(_0x270a58){return _0x175b05[_0xd791('0x30')](_0x51189e)[_0xd791('0x31')](_0x270a58);}};}function respondWithFilteredResult(_0x2c0a96,_0x2523bf){return function(_0x10edc3){if(_0x10edc3){var _0x544848=typeof _0x2523bf[_0xd791('0x32')]==='undefined'&&typeof _0x2523bf[_0xd791('0x33')]==='undefined';var _0x1e8a79=_0x10edc3['count'];var _0x88b955=_0x544848?0x0:_0x2523bf[_0xd791('0x32')];var _0x3818fa=_0x544848?_0x10edc3[_0xd791('0x34')]:_0x2523bf['offset']+_0x2523bf[_0xd791('0x33')];var _0x29d114;if(_0x3818fa>=_0x1e8a79){_0x3818fa=_0x1e8a79;_0x29d114=0xc8;}else{_0x29d114=0xce;}_0x2c0a96['status'](_0x29d114);return _0x2c0a96[_0xd791('0x35')]('Content-Range',_0x88b955+'-'+_0x3818fa+'/'+_0x1e8a79)[_0xd791('0x31')](_0x10edc3);}return null;};}function patchUpdates(_0x5118b3){return function(_0x30d5d6){try{jsonpatch[_0xd791('0x36')](_0x30d5d6,_0x5118b3,!![]);}catch(_0x5b3410){return BPromise[_0xd791('0x37')](_0x5b3410);}return _0x30d5d6['save']();};}function saveUpdates(_0x12d7a6,_0x4f324a){return function(_0xf6ae78){if(_0xf6ae78){return _0xf6ae78['update'](_0x12d7a6)[_0xd791('0x23')](function(_0x369ed4){return _0x369ed4;});}return null;};}function removeEntity(_0x37a576,_0x420281){return function(_0x50d406){if(_0x50d406){return _0x50d406[_0xd791('0x38')]()[_0xd791('0x23')](function(){_0x37a576['status'](0xcc)['end']();});}};}function handleEntityNotFound(_0x3b65c0,_0x5d9b4b){return function(_0x1584d){if(!_0x1584d){_0x3b65c0['sendStatus'](0x194);}return _0x1584d;};}function handleError(_0x4cc3e4,_0xcbdbe8){_0xcbdbe8=_0xcbdbe8||0x1f4;return function(_0x57c488){logger[_0xd791('0x28')](_0x57c488['stack']);if(_0x57c488[_0xd791('0x39')]){delete _0x57c488[_0xd791('0x39')];}_0x4cc3e4[_0xd791('0x30')](_0xcbdbe8)['send'](_0x57c488);};}exports[_0xd791('0x3a')]=function(_0x180bdc,_0x13c297){var _0x583cfd={},_0x4db963={},_0x424270={'count':0x0,'rows':[]};var _0x31aee5=_[_0xd791('0x3b')](db[_0xd791('0x3c')][_0xd791('0x3d')],function(_0x2d4d5d){return{'name':_0x2d4d5d[_0xd791('0x3e')],'type':_0x2d4d5d[_0xd791('0x3f')]['key']};});_0x4db963['model']=_[_0xd791('0x3b')](_0x31aee5,_0xd791('0x39'));_0x4db963[_0xd791('0x40')]=_[_0xd791('0x41')](_0x180bdc['query']);_0x4db963['filters']=_[_0xd791('0x42')](_0x4db963[_0xd791('0x43')],_0x4db963['query']);_0x583cfd[_0xd791('0x44')]=_[_0xd791('0x42')](_0x4db963['model'],qs[_0xd791('0x45')](_0x180bdc['query'][_0xd791('0x45')]));_0x583cfd[_0xd791('0x44')]=_0x583cfd['attributes']['length']?_0x583cfd['attributes']:_0x4db963[_0xd791('0x43')];if(!_0x180bdc['query']['hasOwnProperty']('nolimit')){_0x583cfd[_0xd791('0x33')]=qs[_0xd791('0x33')](_0x180bdc[_0xd791('0x40')][_0xd791('0x33')]);_0x583cfd[_0xd791('0x32')]=qs[_0xd791('0x32')](_0x180bdc['query'][_0xd791('0x32')]);}_0x583cfd[_0xd791('0x46')]=qs[_0xd791('0x47')](_0x180bdc['query']['sort']);_0x583cfd[_0xd791('0x48')]=qs[_0xd791('0x49')](_['pick'](_0x180bdc[_0xd791('0x40')],_0x4db963['filters']),_0x31aee5);if(_0x180bdc[_0xd791('0x40')][_0xd791('0x4a')]){_0x583cfd[_0xd791('0x48')]=_[_0xd791('0x4b')](_0x583cfd[_0xd791('0x48')],{'$or':_['map'](_0x31aee5,function(_0x4e5fd5){if(_0x4e5fd5[_0xd791('0x3f')]!=='VIRTUAL'){var _0x4af3ed={};_0x4af3ed[_0x4e5fd5['name']]={'$like':'%'+_0x180bdc[_0xd791('0x40')][_0xd791('0x4a')]+'%'};return _0x4af3ed;}})});}_0x583cfd=_[_0xd791('0x4b')]({},_0x583cfd,_0x180bdc[_0xd791('0x4c')]);var _0x5dfc5c={'where':_0x583cfd[_0xd791('0x48')]};return db['WhatsappMessage'][_0xd791('0x34')](_0x5dfc5c)[_0xd791('0x23')](function(_0x2d58de){_0x424270['count']=_0x2d58de;if(_0x180bdc[_0xd791('0x40')][_0xd791('0x4d')]){_0x583cfd[_0xd791('0x4e')]=[{'all':!![]}];}return db[_0xd791('0x3c')][_0xd791('0x4f')](_0x583cfd);})[_0xd791('0x23')](function(_0xda1cdd){_0x424270[_0xd791('0x50')]=_0xda1cdd;return _0x424270;})[_0xd791('0x23')](respondWithFilteredResult(_0x13c297,_0x583cfd))[_0xd791('0x2d')](handleError(_0x13c297,null));};exports[_0xd791('0x51')]=function(_0x2d066a,_0x5e72d0){var _0x3826d6={'raw':!![],'where':{'id':_0x2d066a['params']['id']}},_0x2df5b5={};_0x2df5b5['model']=_[_0xd791('0x41')](db['WhatsappMessage'][_0xd791('0x3d')]);_0x2df5b5[_0xd791('0x40')]=_[_0xd791('0x41')](_0x2d066a['query']);_0x2df5b5['filters']=_[_0xd791('0x42')](_0x2df5b5[_0xd791('0x43')],_0x2df5b5[_0xd791('0x40')]);_0x3826d6['attributes']=_['intersection'](_0x2df5b5['model'],qs[_0xd791('0x45')](_0x2d066a[_0xd791('0x40')][_0xd791('0x45')]));_0x3826d6[_0xd791('0x44')]=_0x3826d6[_0xd791('0x44')][_0xd791('0x52')]?_0x3826d6[_0xd791('0x44')]:_0x2df5b5['model'];if(_0x2d066a[_0xd791('0x40')][_0xd791('0x4d')]){_0x3826d6[_0xd791('0x4e')]=[{'all':!![]}];}_0x3826d6=_[_0xd791('0x4b')]({},_0x3826d6,_0x2d066a[_0xd791('0x4c')]);return db[_0xd791('0x3c')][_0xd791('0x53')](_0x3826d6)[_0xd791('0x23')](handleEntityNotFound(_0x5e72d0,null))['then'](respondWithResult(_0x5e72d0,null))[_0xd791('0x2d')](handleError(_0x5e72d0,null));};exports[_0xd791('0x54')]=function(_0x22d6d9,_0x5e89e7){return db[_0xd791('0x3c')]['create'](_0x22d6d9[_0xd791('0x55')],{})[_0xd791('0x23')](respondWithResult(_0x5e89e7,0xc9))[_0xd791('0x2d')](handleError(_0x5e89e7,null));};exports[_0xd791('0x56')]=function(_0x240a83,_0x2b13a8){if(_0x240a83[_0xd791('0x55')]['id']){delete _0x240a83[_0xd791('0x55')]['id'];}return db[_0xd791('0x3c')][_0xd791('0x53')]({'where':{'id':_0x240a83['params']['id']}})[_0xd791('0x23')](handleEntityNotFound(_0x2b13a8,null))['then'](saveUpdates(_0x240a83['body'],null))[_0xd791('0x23')](respondWithResult(_0x2b13a8,null))[_0xd791('0x2d')](handleError(_0x2b13a8,null));};exports[_0xd791('0x38')]=function(_0x5dc930,_0x56a682){return db[_0xd791('0x3c')]['find']({'where':{'id':_0x5dc930[_0xd791('0x57')]['id']}})[_0xd791('0x23')](handleEntityNotFound(_0x56a682,null))['then'](removeEntity(_0x56a682,null))[_0xd791('0x2d')](handleError(_0x56a682,null));};exports[_0xd791('0x58')]=function(_0x4859c6,_0x319b5c){return db[_0xd791('0x3c')]['describe']()[_0xd791('0x23')](respondWithResult(_0x319b5c,null))['catch'](handleError(_0x319b5c,null));};var interaction_log=require('../../config/logger')(_0xd791('0x59'));exports[_0xd791('0x5a')]=function(_0x316eec,_0x36e503,_0x437ff3){var _0x142061={'agent':{},'channel':_0xd791('0x5b')};if(_0x316eec[_0xd791('0x55')]['id']){delete _0x316eec[_0xd791('0x55')]['id'];}_0x316eec[_0xd791('0x55')][_0xd791('0x5c')]=!![];_0x316eec[_0xd791('0x55')][_0xd791('0x5d')]=moment()[_0xd791('0x5e')]('YYYY-MM-DD\x20HH:mm:ss');_0x316eec[_0xd791('0x55')][_0xd791('0x5f')]=_0x316eec[_0xd791('0x55')]['UserId']||_0x316eec[_0xd791('0x60')]['id'];_0x142061['agent']['id']=_0x316eec[_0xd791('0x55')]['UserId'];return db['WhatsappMessage']['find']({'where':{'id':_0x316eec[_0xd791('0x57')]['id'],'UserId':null}})[_0xd791('0x23')](handleEntityNotFound(_0x36e503,null))[_0xd791('0x23')](saveUpdates(_0x316eec['body'],null))['then'](function(_0x577284){if(_0x577284){_0x142061[_0xd791('0x2b')]=_0x577284[_0xd791('0x61')]({'plain':!![]});return db[_0xd791('0x62')]['find']({'where':{'id':_0x577284[_0xd791('0x63')]}});}return null;})[_0xd791('0x23')](handleEntityNotFound(_0x36e503,null))[_0xd791('0x23')](function(_0x2ccafa){if(_0x2ccafa){return _0x2ccafa[_0xd791('0x56')]({'UserId':_0x316eec[_0xd791('0x55')]['UserId'],'read1stAt':_['isNil'](_0x2ccafa[_0xd791('0x64')])?moment()[_0xd791('0x5e')]('YYYY-MM-DD\x20HH:mm:ss'):undefined});}return null;})['then'](function(_0x366c81){if(_0x366c81){_0x142061['interaction']=_0x366c81[_0xd791('0x61')]({'plain':!![]});interaction_log[_0xd791('0x24')]('[WHATSAPPMESSAGE:ACCEPT]\x20id=%s\x20name=%s\x20role=%s\x20interaction=%s\x20body=%s',_0x316eec[_0xd791('0x60')]['id'],_0x316eec[_0xd791('0x60')][_0xd791('0x39')],_0x316eec[_0xd791('0x60')][_0xd791('0x65')],_0x142061[_0xd791('0x66')]['id'],_0x316eec[_0xd791('0x55')]?JSON[_0xd791('0x67')](_0x316eec[_0xd791('0x55')]):_0xd791('0x68'));return respondWithRpcPromise(_0xd791('0x69'),_0xd791('0x6a'),_0x142061);}return null;})[_0xd791('0x23')](function(_0x9a4f83){var _0x3d575f=_0xd791('0x6b')+_0x9a4f83[_0xd791('0x2b')]['ContactId'];return db[_0xd791('0x6c')]['query'](_0x3d575f,{'type':db[_0xd791('0x6d')][_0xd791('0x6e')]['SELECT'],'raw':!![]})['then'](function(_0x4ecf86){return _0x4ecf86;});})[_0xd791('0x23')](function(_0x6832f2){if(_0x6832f2){_0x142061[_0xd791('0x2b')][_0xd791('0x6f')]=_0x6832f2[0x0];if(!_0x316eec['body'][_0xd791('0x5f')])return;return db[_0xd791('0x70')][_0xd791('0x53')]({'where':{'id':_0x316eec['body']['UserId'],'role':_0xd791('0x71')},'attributes':['id',_0xd791('0x39'),_0xd791('0x72'),_0xd791('0x73'),_0xd791('0x74')],'raw':!![]});}return null;})[_0xd791('0x23')](function(_0x480b40){if(!_0x480b40)return null;_0x142061['message'][_0xd791('0x71')]=_0x480b40;return _0x142061;})[_0xd791('0x23')](function(_0x218580){if(_0x218580){if(_0x316eec['body'][_0xd791('0x75')]){_0x142061['message'][_0xd791('0x76')]=util['format'](_0xd791('0x77'),_0x316eec[_0xd791('0x60')][_0xd791('0x39')]);_0x142061[_0xd791('0x2b')][_0xd791('0x78')]=_0x142061['channel'];_0x142061[_0xd791('0x2b')][_0xd791('0x79')]=_0x142061[_0xd791('0x78')];_0x142061['message'][_0xd791('0x7a')]=_0xd791('0x5a');return respondWithRpcPromise('EventManager',_0xd791('0x7b'),{'event':'acceptmessage','message':_0x142061[_0xd791('0x2b')]},client9002)[_0xd791('0x23')](function(){return _0x142061;});}return _0x142061;}return null;})[_0xd791('0x23')](respondWithResult(_0x36e503,null))[_0xd791('0x2d')](handleError(_0x36e503,null));};var interaction_log=require('../../config/logger')(_0xd791('0x59'));exports['reject']=function(_0x3b4dbc,_0x3306a3,_0x50c149){var _0x119f5b={'agent':{},'channel':_0xd791('0x5b')};if(_0x3b4dbc[_0xd791('0x55')]['id']){delete _0x3b4dbc[_0xd791('0x55')]['id'];}_0x3b4dbc[_0xd791('0x55')]['UserId']=_0x3b4dbc[_0xd791('0x55')]['UserId']||_0x3b4dbc[_0xd791('0x60')]['id'];_0x119f5b[_0xd791('0x71')]['id']=_0x3b4dbc[_0xd791('0x55')][_0xd791('0x5f')];return db[_0xd791('0x3c')]['find']({'where':{'id':_0x3b4dbc['params']['id'],'UserId':null}})[_0xd791('0x23')](handleEntityNotFound(_0x3306a3,null))['then'](function(_0x26f87f){if(_0x26f87f){_0x119f5b[_0xd791('0x2b')]=_0x26f87f[_0xd791('0x61')]({'plain':!![]});return db['WhatsappInteraction'][_0xd791('0x53')]({'where':{'id':_0x26f87f[_0xd791('0x63')]}});}return null;})[_0xd791('0x23')](handleEntityNotFound(_0x3306a3,null))[_0xd791('0x23')](function(_0x294aab){if(_0x294aab){_0x119f5b[_0xd791('0x66')]=_0x294aab[_0xd791('0x61')]({'plain':!![]});interaction_log[_0xd791('0x24')](_0xd791('0x7c'),_0x3b4dbc[_0xd791('0x60')]['id'],_0x3b4dbc['user'][_0xd791('0x39')],_0x3b4dbc['user'][_0xd791('0x65')],_0x119f5b['interaction']['id'],_0x3b4dbc['body']?JSON[_0xd791('0x67')](_0x3b4dbc[_0xd791('0x55')]):_0xd791('0x68'));return respondWithRpcPromise(_0xd791('0x7d'),_0xd791('0x7e'),_0x119f5b);}return null;})[_0xd791('0x23')](function(_0xf1d0f4){var _0xb6b868=_0xd791('0x6b')+_0xf1d0f4['message'][_0xd791('0x7f')];return db[_0xd791('0x6c')][_0xd791('0x40')](_0xb6b868,{'type':db['Sequelize'][_0xd791('0x6e')][_0xd791('0x80')],'raw':!![]})['then'](function(_0x420a11){return _0x420a11;});})[_0xd791('0x23')](function(_0x4b0822){if(_0x4b0822){_0x119f5b[_0xd791('0x2b')]['contact']=_0x4b0822[0x0];if(!_0x3b4dbc[_0xd791('0x55')][_0xd791('0x5f')])return;return db[_0xd791('0x70')][_0xd791('0x53')]({'where':{'id':_0x3b4dbc['body'][_0xd791('0x5f')],'role':_0xd791('0x71')},'attributes':['id',_0xd791('0x39'),_0xd791('0x72'),_0xd791('0x73'),_0xd791('0x74')],'raw':!![]});}return null;})[_0xd791('0x23')](function(_0x8f0334){if(!_0x8f0334)return null;_0x119f5b[_0xd791('0x2b')]['agent']=_0x8f0334;return _0x119f5b;})[_0xd791('0x23')](function(_0x566c06){if(_0x566c06){_0x566c06[_0xd791('0x2b')][_0xd791('0x76')]=util[_0xd791('0x5e')]('SIP/%s',_0x3b4dbc['user']['name']);_0x566c06[_0xd791('0x2b')][_0xd791('0x78')]=_0x119f5b[_0xd791('0x78')];_0x566c06[_0xd791('0x2b')]['motionChannel']=_0x119f5b['channel'];_0x566c06[_0xd791('0x2b')][_0xd791('0x7a')]=_0xd791('0x37');respondWithRpcPromise(_0xd791('0x7b'),_0xd791('0x7b'),{'event':_0xd791('0x81'),'message':_0x566c06[_0xd791('0x2b')]},client9002);return _0x119f5b;}return null;})[_0xd791('0x23')](respondWithResult(_0x3306a3,null))[_0xd791('0x2d')](handleError(_0x3306a3,null));};exports[_0xd791('0x30')]=function(_0x2b6b18,_0x582f47,_0x5b5118){if(_0x2b6b18[_0xd791('0x55')]['id']){delete _0x2b6b18['body']['id'];}var _0x5eb62e;return db[_0xd791('0x3c')][_0xd791('0x53')]({'where':{'id':_0x2b6b18[_0xd791('0x57')]['id']}})[_0xd791('0x23')](handleEntityNotFound(_0x582f47,null))[_0xd791('0x23')](function(_0x305255){if(_0x305255){_0x5eb62e=_0x305255;return db[_0xd791('0x82')][_0xd791('0x53')]({'where':{'id':_0x305255['WhatsappAccountId']}});}})[_0xd791('0x23')](handleEntityNotFound(_0x582f47,null))[_0xd791('0x23')](function(_0x273a12){if(_0x273a12){logger[_0xd791('0x26')](_0xd791('0x83'),'status',_0xd791('0x84'),_0x273a12[_0xd791('0x3f')],util['inspect'](_0x2b6b18[_0xd791('0x55')],{'showHidden':![],'depth':null}));switch(_0x273a12[_0xd791('0x3f')]){case _0xd791('0x85'):if(_0x2b6b18[_0xd791('0x55')][_0xd791('0x86')]&&_0x2b6b18['body'][_0xd791('0x86')]===_0x5eb62e[_0xd791('0x87')]&&_0x2b6b18[_0xd791('0x55')]['MessageStatus']&&_0x2b6b18[_0xd791('0x55')]['MessageStatus']===_0xd791('0x5c')){return _0x5eb62e[_0xd791('0x56')]({'read':!![]});}else{logger[_0xd791('0x28')](_0xd791('0x88'),_0xd791('0x30'),_0xd791('0x85'),util[_0xd791('0x89')](_0x2b6b18[_0xd791('0x55')],{'showHidden':![],'depth':null}));}break;}return _0x5eb62e;}})[_0xd791('0x23')](respondWithResult(_0x582f47,null))['catch'](handleError(_0x582f47,null));};
\ No newline at end of file