Built motion from commit 538092ac.|2.6.10
[motion2.git] / server / api / whatsappMessage / whatsappMessage.controller.js
index ab47be3..016a17e 100644 (file)
@@ -15,4 +15,4 @@
 // * treaties. The SOFTWARE PRODUCT is licensed, not sold.                        *
 // *                                                                       *
 // *************************************************************************
-var _0x578f=['inspect','twilio','MessageSid','messageId','MessageStatus','WhatsappAccount,\x20%s,\x20%s,\x20%s','zip-dir','fast-json-patch','moment','bluebird','mustache','util','path','sox','to-csv','ejs','fs-extra','lodash','squel','crypto','desk.js','querystring','ioredis','../../components/auth/service','../../components/parsers/qs','../../config/license/hardware','api','../../config/utils','../../config/license/util','../../mysqldb','defaults','redis','socket.io-emitter','./whatsappMessage.socket','register','jayson/promise','client','http','request','then','WhatsappMessage,\x20%s,\x20%s','debug','WhatsappMessage,\x20%s,\x20%s,\x20%s','stringify','error','code','message','info','request\x20sent','result','sendStatus','end','status','json','offset','undefined','count','limit','set','Content-Range','apply','reject','save','update','destroy','stack','name','send','index','map','WhatsappMessage','rawAttributes','type','model','query','keys','filters','intersection','attributes','fields','length','hasOwnProperty','nolimit','order','sort','where','pick','filter','merge','VIRTUAL','options','includeAll','include','findAll','rows','catch','show','params','find','create','body','describe','accept','read','format','YYYY-MM-DD\x20HH:mm:ss','UserId','agent','get','WhatsappInteractionId','isNil','read1stAt','[WHATSAPPMESSAGE:ACCEPT]\x20id=%s\x20name=%s\x20role=%s\x20interaction=%s\x20body=%s','user','role','interaction','null','AcceptMessage','acceptMessage','SELECT\x20*\x20FROM\x20cm_contacts\x20WHERE\x20id\x20=\x20','ContactId','sequelize','SELECT','contact','User','fullname','email','internal','manual','interface','SIP/%s','channel','event','EventManager','acceptmessage','../../config/logger','whatsapp-interactions','[WHATSAPPMESSAGE:REJECT]\x20id=%s\x20name=%s\x20role=%s\x20interaction=%s\x20body=%s','RejectMessage','rejectMessage','Sequelize','QueryTypes','motionChannel','rejectmessage','WhatsappAccount','WhatsappAccountId','received\x20delivery\x20report\x20from'];(function(_0x27062d,_0x24b179){var _0x4f1478=function(_0x3b4489){while(--_0x3b4489){_0x27062d['push'](_0x27062d['shift']());}};_0x4f1478(++_0x24b179);}(_0x578f,0x12c));var _0xf578=function(_0x194772,_0x43a800){_0x194772=_0x194772-0x0;var _0x2d0daa=_0x578f[_0x194772];return _0x2d0daa;};'use strict';var emlformat=require('eml-format');var rimraf=require('rimraf');var zipdir=require(_0xf578('0x0'));var jsonpatch=require(_0xf578('0x1'));var rp=require('request-promise');var moment=require(_0xf578('0x2'));var BPromise=require(_0xf578('0x3'));var Mustache=require(_0xf578('0x4'));var util=require(_0xf578('0x5'));var path=require(_0xf578('0x6'));var sox=require(_0xf578('0x7'));var csv=require(_0xf578('0x8'));var ejs=require(_0xf578('0x9'));var fs=require('fs');var fs_extra=require(_0xf578('0xa'));var _=require(_0xf578('0xb'));var squel=require(_0xf578('0xc'));var crypto=require(_0xf578('0xd'));var jsforce=require('jsforce');var deskjs=require(_0xf578('0xe'));var toCsv=require('to-csv');var querystring=require(_0xf578('0xf'));var Papa=require('papaparse');var Redis=require(_0xf578('0x10'));var authService=require(_0xf578('0x11'));var qs=require(_0xf578('0x12'));var as=require('../../components/parsers/advancedSearch');var hardwareService=require(_0xf578('0x13'));var logger=require('../../config/logger')(_0xf578('0x14'));var utils=require(_0xf578('0x15'));var config=require('../../config/environment');var licenseUtil=require(_0xf578('0x16'));var db=require(_0xf578('0x17'))['db'];config['redis']=_[_0xf578('0x18')](config[_0xf578('0x19')],{'host':'localhost','port':0x18eb});var socket=require(_0xf578('0x1a'))(new Redis(config[_0xf578('0x19')]));require(_0xf578('0x1b'))[_0xf578('0x1c')](socket);var jayson=require(_0xf578('0x1d'));var client=jayson[_0xf578('0x1e')][_0xf578('0x1f')]({'port':0x232c});var client9002=jayson['client']['http']({'port':0x232a});function respondWithRpcPromise(_0x3b9659,_0x466948,_0xc6ccd2,_0x2e6df1){return new BPromise(function(_0x21eac8,_0x488050){var _0x37a9d0=_0x2e6df1||client;return _0x37a9d0[_0xf578('0x20')](_0x3b9659,_0xc6ccd2)[_0xf578('0x21')](function(_0x189541){logger['info'](_0xf578('0x22'),_0x466948,'request\x20sent');logger[_0xf578('0x23')](_0xf578('0x24'),_0x466948,'request\x20sent',JSON[_0xf578('0x25')](_0x189541));if(_0x189541[_0xf578('0x26')]){if(_0x189541[_0xf578('0x26')][_0xf578('0x27')]===0x1f4){logger[_0xf578('0x26')](_0xf578('0x22'),_0x466948,_0x189541[_0xf578('0x26')][_0xf578('0x28')]);return _0x488050(_0x189541[_0xf578('0x26')][_0xf578('0x28')]);}logger[_0xf578('0x26')]('WhatsappMessage,\x20%s,\x20%s',_0x466948,_0x189541[_0xf578('0x26')][_0xf578('0x28')]);return _0x21eac8(_0x189541[_0xf578('0x26')][_0xf578('0x28')]);}else{logger[_0xf578('0x29')]('WhatsappMessage,\x20%s,\x20%s',_0x466948,_0xf578('0x2a'));_0x21eac8(_0x189541[_0xf578('0x2b')]['message']);}})['catch'](function(_0x1e0f57){logger[_0xf578('0x26')](_0xf578('0x22'),_0x466948,_0x1e0f57);_0x488050(_0x1e0f57);});});}function respondWithStatusCode(_0x2a6d65,_0x3103aa){_0x3103aa=_0x3103aa||0xcc;return function(_0x24abb0){if(_0x24abb0){return _0x2a6d65[_0xf578('0x2c')](_0x3103aa);}return _0x2a6d65['status'](_0x3103aa)[_0xf578('0x2d')]();};}function respondWithResult(_0x5f13a8,_0xee5ee6){_0xee5ee6=_0xee5ee6||0xc8;return function(_0xbed8f9){if(_0xbed8f9){return _0x5f13a8[_0xf578('0x2e')](_0xee5ee6)[_0xf578('0x2f')](_0xbed8f9);}};}function respondWithFilteredResult(_0x37a12a,_0x410247){return function(_0x4b9f63){if(_0x4b9f63){var _0x2dacf7=typeof _0x410247[_0xf578('0x30')]==='undefined'&&typeof _0x410247['limit']===_0xf578('0x31');var _0x3e16ef=_0x4b9f63[_0xf578('0x32')];var _0xe5ff9d=_0x2dacf7?0x0:_0x410247[_0xf578('0x30')];var _0x25d1d6=_0x2dacf7?_0x4b9f63[_0xf578('0x32')]:_0x410247[_0xf578('0x30')]+_0x410247[_0xf578('0x33')];var _0x5cebfa;if(_0x25d1d6>=_0x3e16ef){_0x25d1d6=_0x3e16ef;_0x5cebfa=0xc8;}else{_0x5cebfa=0xce;}_0x37a12a['status'](_0x5cebfa);return _0x37a12a[_0xf578('0x34')](_0xf578('0x35'),_0xe5ff9d+'-'+_0x25d1d6+'/'+_0x3e16ef)['json'](_0x4b9f63);}return null;};}function patchUpdates(_0x544937){return function(_0xc466f0){try{jsonpatch[_0xf578('0x36')](_0xc466f0,_0x544937,!![]);}catch(_0x4bcb89){return BPromise[_0xf578('0x37')](_0x4bcb89);}return _0xc466f0[_0xf578('0x38')]();};}function saveUpdates(_0x3eccd2,_0x595a93){return function(_0x3fd0b4){if(_0x3fd0b4){return _0x3fd0b4[_0xf578('0x39')](_0x3eccd2)['then'](function(_0x5b0477){return _0x5b0477;});}return null;};}function removeEntity(_0x7cefe2,_0x2cffae){return function(_0x2258cd){if(_0x2258cd){return _0x2258cd[_0xf578('0x3a')]()[_0xf578('0x21')](function(){_0x7cefe2['status'](0xcc)[_0xf578('0x2d')]();});}};}function handleEntityNotFound(_0x225f84,_0x8facad){return function(_0x29fe79){if(!_0x29fe79){_0x225f84[_0xf578('0x2c')](0x194);}return _0x29fe79;};}function handleError(_0x101f86,_0x3df202){_0x3df202=_0x3df202||0x1f4;return function(_0x5c5b05){logger[_0xf578('0x26')](_0x5c5b05[_0xf578('0x3b')]);if(_0x5c5b05[_0xf578('0x3c')]){delete _0x5c5b05['name'];}_0x101f86[_0xf578('0x2e')](_0x3df202)[_0xf578('0x3d')](_0x5c5b05);};}exports[_0xf578('0x3e')]=function(_0x362374,_0x46a54d){var _0x2c7356={},_0x3b774c={},_0x4e11b6={'count':0x0,'rows':[]};var _0x1f769a=_[_0xf578('0x3f')](db[_0xf578('0x40')][_0xf578('0x41')],function(_0x8d5b83){return{'name':_0x8d5b83['fieldName'],'type':_0x8d5b83[_0xf578('0x42')]['key']};});_0x3b774c[_0xf578('0x43')]=_[_0xf578('0x3f')](_0x1f769a,_0xf578('0x3c'));_0x3b774c[_0xf578('0x44')]=_[_0xf578('0x45')](_0x362374[_0xf578('0x44')]);_0x3b774c[_0xf578('0x46')]=_[_0xf578('0x47')](_0x3b774c[_0xf578('0x43')],_0x3b774c['query']);_0x2c7356[_0xf578('0x48')]=_['intersection'](_0x3b774c[_0xf578('0x43')],qs[_0xf578('0x49')](_0x362374['query'][_0xf578('0x49')]));_0x2c7356[_0xf578('0x48')]=_0x2c7356[_0xf578('0x48')][_0xf578('0x4a')]?_0x2c7356[_0xf578('0x48')]:_0x3b774c[_0xf578('0x43')];if(!_0x362374[_0xf578('0x44')][_0xf578('0x4b')](_0xf578('0x4c'))){_0x2c7356[_0xf578('0x33')]=qs['limit'](_0x362374[_0xf578('0x44')]['limit']);_0x2c7356[_0xf578('0x30')]=qs['offset'](_0x362374[_0xf578('0x44')]['offset']);}_0x2c7356[_0xf578('0x4d')]=qs['sort'](_0x362374[_0xf578('0x44')][_0xf578('0x4e')]);_0x2c7356[_0xf578('0x4f')]=qs[_0xf578('0x46')](_[_0xf578('0x50')](_0x362374['query'],_0x3b774c['filters']),_0x1f769a);if(_0x362374[_0xf578('0x44')][_0xf578('0x51')]){_0x2c7356[_0xf578('0x4f')]=_[_0xf578('0x52')](_0x2c7356['where'],{'$or':_[_0xf578('0x3f')](_0x1f769a,function(_0x4e2e3b){if(_0x4e2e3b[_0xf578('0x42')]!==_0xf578('0x53')){var _0x38d508={};_0x38d508[_0x4e2e3b['name']]={'$like':'%'+_0x362374[_0xf578('0x44')][_0xf578('0x51')]+'%'};return _0x38d508;}})});}_0x2c7356=_[_0xf578('0x52')]({},_0x2c7356,_0x362374[_0xf578('0x54')]);var _0x1d7b05={'where':_0x2c7356[_0xf578('0x4f')]};return db[_0xf578('0x40')][_0xf578('0x32')](_0x1d7b05)['then'](function(_0x35f152){_0x4e11b6[_0xf578('0x32')]=_0x35f152;if(_0x362374[_0xf578('0x44')][_0xf578('0x55')]){_0x2c7356[_0xf578('0x56')]=[{'all':!![]}];}return db[_0xf578('0x40')][_0xf578('0x57')](_0x2c7356);})[_0xf578('0x21')](function(_0x45dfe9){_0x4e11b6[_0xf578('0x58')]=_0x45dfe9;return _0x4e11b6;})[_0xf578('0x21')](respondWithFilteredResult(_0x46a54d,_0x2c7356))[_0xf578('0x59')](handleError(_0x46a54d,null));};exports[_0xf578('0x5a')]=function(_0x39472f,_0xab697a){var _0x3ecc5e={'raw':!![],'where':{'id':_0x39472f[_0xf578('0x5b')]['id']}},_0xb9b2a6={};_0xb9b2a6[_0xf578('0x43')]=_[_0xf578('0x45')](db['WhatsappMessage'][_0xf578('0x41')]);_0xb9b2a6[_0xf578('0x44')]=_[_0xf578('0x45')](_0x39472f['query']);_0xb9b2a6[_0xf578('0x46')]=_[_0xf578('0x47')](_0xb9b2a6[_0xf578('0x43')],_0xb9b2a6[_0xf578('0x44')]);_0x3ecc5e[_0xf578('0x48')]=_[_0xf578('0x47')](_0xb9b2a6[_0xf578('0x43')],qs[_0xf578('0x49')](_0x39472f['query'][_0xf578('0x49')]));_0x3ecc5e[_0xf578('0x48')]=_0x3ecc5e['attributes'][_0xf578('0x4a')]?_0x3ecc5e['attributes']:_0xb9b2a6[_0xf578('0x43')];if(_0x39472f[_0xf578('0x44')][_0xf578('0x55')]){_0x3ecc5e[_0xf578('0x56')]=[{'all':!![]}];}_0x3ecc5e=_[_0xf578('0x52')]({},_0x3ecc5e,_0x39472f[_0xf578('0x54')]);return db['WhatsappMessage'][_0xf578('0x5c')](_0x3ecc5e)[_0xf578('0x21')](handleEntityNotFound(_0xab697a,null))[_0xf578('0x21')](respondWithResult(_0xab697a,null))[_0xf578('0x59')](handleError(_0xab697a,null));};exports['create']=function(_0x27bd5e,_0x1461f0){return db['WhatsappMessage'][_0xf578('0x5d')](_0x27bd5e[_0xf578('0x5e')],{})[_0xf578('0x21')](respondWithResult(_0x1461f0,0xc9))[_0xf578('0x59')](handleError(_0x1461f0,null));};exports[_0xf578('0x39')]=function(_0xa628ba,_0x499192){if(_0xa628ba['body']['id']){delete _0xa628ba[_0xf578('0x5e')]['id'];}return db[_0xf578('0x40')][_0xf578('0x5c')]({'where':{'id':_0xa628ba['params']['id']}})['then'](handleEntityNotFound(_0x499192,null))[_0xf578('0x21')](saveUpdates(_0xa628ba[_0xf578('0x5e')],null))[_0xf578('0x21')](respondWithResult(_0x499192,null))[_0xf578('0x59')](handleError(_0x499192,null));};exports[_0xf578('0x3a')]=function(_0x7af990,_0x4827cc){return db[_0xf578('0x40')][_0xf578('0x5c')]({'where':{'id':_0x7af990['params']['id']}})[_0xf578('0x21')](handleEntityNotFound(_0x4827cc,null))[_0xf578('0x21')](removeEntity(_0x4827cc,null))[_0xf578('0x59')](handleError(_0x4827cc,null));};exports[_0xf578('0x5f')]=function(_0xa6dc3c,_0x6c8fa6){return db[_0xf578('0x40')][_0xf578('0x5f')]()[_0xf578('0x21')](respondWithResult(_0x6c8fa6,null))[_0xf578('0x59')](handleError(_0x6c8fa6,null));};var interaction_log=require('../../config/logger')('whatsapp-interactions');exports[_0xf578('0x60')]=function(_0x214493,_0x375140,_0x249255){var _0x35b8f8={'agent':{},'channel':'whatsapp'};if(_0x214493[_0xf578('0x5e')]['id']){delete _0x214493['body']['id'];}_0x214493[_0xf578('0x5e')][_0xf578('0x61')]=!![];_0x214493[_0xf578('0x5e')]['readAt']=moment()[_0xf578('0x62')](_0xf578('0x63'));_0x214493[_0xf578('0x5e')]['UserId']=_0x214493[_0xf578('0x5e')][_0xf578('0x64')]||_0x214493['user']['id'];_0x35b8f8[_0xf578('0x65')]['id']=_0x214493[_0xf578('0x5e')][_0xf578('0x64')];return db[_0xf578('0x40')]['find']({'where':{'id':_0x214493['params']['id'],'UserId':null}})[_0xf578('0x21')](handleEntityNotFound(_0x375140,null))[_0xf578('0x21')](saveUpdates(_0x214493[_0xf578('0x5e')],null))[_0xf578('0x21')](function(_0x46a99b){if(_0x46a99b){_0x35b8f8[_0xf578('0x28')]=_0x46a99b[_0xf578('0x66')]({'plain':!![]});return db['WhatsappInteraction'][_0xf578('0x5c')]({'where':{'id':_0x46a99b[_0xf578('0x67')]}});}return null;})[_0xf578('0x21')](handleEntityNotFound(_0x375140,null))[_0xf578('0x21')](function(_0x54e27a){if(_0x54e27a){return _0x54e27a[_0xf578('0x39')]({'UserId':_0x214493[_0xf578('0x5e')][_0xf578('0x64')],'read1stAt':_[_0xf578('0x68')](_0x54e27a[_0xf578('0x69')])?moment()['format'](_0xf578('0x63')):undefined});}return null;})[_0xf578('0x21')](function(_0xd8fad4){if(_0xd8fad4){_0x35b8f8['interaction']=_0xd8fad4['get']({'plain':!![]});interaction_log[_0xf578('0x29')](_0xf578('0x6a'),_0x214493[_0xf578('0x6b')]['id'],_0x214493[_0xf578('0x6b')][_0xf578('0x3c')],_0x214493[_0xf578('0x6b')][_0xf578('0x6c')],_0x35b8f8[_0xf578('0x6d')]['id'],_0x214493[_0xf578('0x5e')]?JSON[_0xf578('0x25')](_0x214493[_0xf578('0x5e')]):_0xf578('0x6e'));return respondWithRpcPromise(_0xf578('0x6f'),_0xf578('0x70'),_0x35b8f8);}return null;})['then'](function(_0x27c46){var _0x3d72a2=_0xf578('0x71')+_0x27c46[_0xf578('0x28')][_0xf578('0x72')];return db[_0xf578('0x73')]['query'](_0x3d72a2,{'type':db['Sequelize']['QueryTypes'][_0xf578('0x74')],'raw':!![]})[_0xf578('0x21')](function(_0x325352){return _0x325352;});})[_0xf578('0x21')](function(_0x187c51){if(_0x187c51){_0x35b8f8[_0xf578('0x28')][_0xf578('0x75')]=_0x187c51[0x0];if(!_0x214493[_0xf578('0x5e')][_0xf578('0x64')])return;return db[_0xf578('0x76')][_0xf578('0x5c')]({'where':{'id':_0x214493[_0xf578('0x5e')]['UserId'],'role':'agent'},'attributes':['id','name',_0xf578('0x77'),_0xf578('0x78'),_0xf578('0x79')],'raw':!![]});}return null;})[_0xf578('0x21')](function(_0x4285c8){if(!_0x4285c8)return null;_0x35b8f8[_0xf578('0x28')][_0xf578('0x65')]=_0x4285c8;return _0x35b8f8;})[_0xf578('0x21')](function(_0x561b76){if(_0x561b76){if(_0x214493[_0xf578('0x5e')][_0xf578('0x7a')]){_0x35b8f8[_0xf578('0x28')][_0xf578('0x7b')]=util['format'](_0xf578('0x7c'),_0x214493['user'][_0xf578('0x3c')]);_0x35b8f8[_0xf578('0x28')][_0xf578('0x7d')]=_0x35b8f8[_0xf578('0x7d')];_0x35b8f8[_0xf578('0x28')]['motionChannel']=_0x35b8f8['channel'];_0x35b8f8[_0xf578('0x28')][_0xf578('0x7e')]=_0xf578('0x60');return respondWithRpcPromise(_0xf578('0x7f'),_0xf578('0x7f'),{'event':_0xf578('0x80'),'message':_0x35b8f8[_0xf578('0x28')]},client9002)[_0xf578('0x21')](function(){return _0x35b8f8;});}return _0x35b8f8;}return null;})[_0xf578('0x21')](respondWithResult(_0x375140,null))['catch'](handleError(_0x375140,null));};var interaction_log=require(_0xf578('0x81'))(_0xf578('0x82'));exports[_0xf578('0x37')]=function(_0x285426,_0x476d85,_0x15e791){var _0x4cfa57={'agent':{},'channel':'whatsapp'};if(_0x285426[_0xf578('0x5e')]['id']){delete _0x285426[_0xf578('0x5e')]['id'];}_0x285426[_0xf578('0x5e')]['UserId']=_0x285426[_0xf578('0x5e')]['UserId']||_0x285426[_0xf578('0x6b')]['id'];_0x4cfa57[_0xf578('0x65')]['id']=_0x285426[_0xf578('0x5e')][_0xf578('0x64')];return db[_0xf578('0x40')]['find']({'where':{'id':_0x285426[_0xf578('0x5b')]['id'],'UserId':null}})[_0xf578('0x21')](handleEntityNotFound(_0x476d85,null))[_0xf578('0x21')](function(_0x5b4aad){if(_0x5b4aad){_0x4cfa57['message']=_0x5b4aad[_0xf578('0x66')]({'plain':!![]});return db['WhatsappInteraction'][_0xf578('0x5c')]({'where':{'id':_0x5b4aad[_0xf578('0x67')]}});}return null;})[_0xf578('0x21')](handleEntityNotFound(_0x476d85,null))[_0xf578('0x21')](function(_0x52e17f){if(_0x52e17f){_0x4cfa57[_0xf578('0x6d')]=_0x52e17f['get']({'plain':!![]});interaction_log[_0xf578('0x29')](_0xf578('0x83'),_0x285426[_0xf578('0x6b')]['id'],_0x285426['user'][_0xf578('0x3c')],_0x285426['user'][_0xf578('0x6c')],_0x4cfa57[_0xf578('0x6d')]['id'],_0x285426['body']?JSON[_0xf578('0x25')](_0x285426[_0xf578('0x5e')]):'null');return respondWithRpcPromise(_0xf578('0x84'),_0xf578('0x85'),_0x4cfa57);}return null;})[_0xf578('0x21')](function(_0x4d585b){var _0x6fc5c7='SELECT\x20*\x20FROM\x20cm_contacts\x20WHERE\x20id\x20=\x20'+_0x4d585b[_0xf578('0x28')][_0xf578('0x72')];return db[_0xf578('0x73')][_0xf578('0x44')](_0x6fc5c7,{'type':db[_0xf578('0x86')][_0xf578('0x87')][_0xf578('0x74')],'raw':!![]})[_0xf578('0x21')](function(_0x256e9d){return _0x256e9d;});})['then'](function(_0xe793b8){if(_0xe793b8){_0x4cfa57[_0xf578('0x28')][_0xf578('0x75')]=_0xe793b8[0x0];if(!_0x285426[_0xf578('0x5e')]['UserId'])return;return db['User'][_0xf578('0x5c')]({'where':{'id':_0x285426[_0xf578('0x5e')][_0xf578('0x64')],'role':'agent'},'attributes':['id',_0xf578('0x3c'),_0xf578('0x77'),'email','internal'],'raw':!![]});}return null;})[_0xf578('0x21')](function(_0xadf44){if(!_0xadf44)return null;_0x4cfa57[_0xf578('0x28')]['agent']=_0xadf44;return _0x4cfa57;})[_0xf578('0x21')](function(_0x3f2d42){if(_0x3f2d42){_0x3f2d42['message'][_0xf578('0x7b')]=util[_0xf578('0x62')](_0xf578('0x7c'),_0x285426[_0xf578('0x6b')][_0xf578('0x3c')]);_0x3f2d42['message'][_0xf578('0x7d')]=_0x4cfa57[_0xf578('0x7d')];_0x3f2d42['message'][_0xf578('0x88')]=_0x4cfa57['channel'];_0x3f2d42[_0xf578('0x28')][_0xf578('0x7e')]=_0xf578('0x37');respondWithRpcPromise(_0xf578('0x7f'),_0xf578('0x7f'),{'event':_0xf578('0x89'),'message':_0x3f2d42[_0xf578('0x28')]},client9002);return _0x4cfa57;}return null;})[_0xf578('0x21')](respondWithResult(_0x476d85,null))['catch'](handleError(_0x476d85,null));};exports['status']=function(_0x59bb45,_0x447169,_0x8087af){if(_0x59bb45[_0xf578('0x5e')]['id']){delete _0x59bb45['body']['id'];}var _0x2ec91b;return db['WhatsappMessage']['find']({'where':{'id':_0x59bb45['params']['id']}})[_0xf578('0x21')](handleEntityNotFound(_0x447169,null))[_0xf578('0x21')](function(_0x52d6f8){if(_0x52d6f8){_0x2ec91b=_0x52d6f8;return db[_0xf578('0x8a')][_0xf578('0x5c')]({'where':{'id':_0x52d6f8[_0xf578('0x8b')]}});}})[_0xf578('0x21')](handleEntityNotFound(_0x447169,null))[_0xf578('0x21')](function(_0x5dd7de){if(_0x5dd7de){logger[_0xf578('0x23')]('WhatsppMessage,\x20%s,\x20%s,\x20%s',_0xf578('0x2e'),_0xf578('0x8c'),_0x5dd7de[_0xf578('0x42')],util[_0xf578('0x8d')](_0x59bb45['body'],{'showHidden':![],'depth':null}));switch(_0x5dd7de['type']){case _0xf578('0x8e'):if(_0x59bb45[_0xf578('0x5e')][_0xf578('0x8f')]&&_0x59bb45[_0xf578('0x5e')]['MessageSid']===_0x2ec91b[_0xf578('0x90')]&&_0x59bb45['body']['MessageStatus']&&_0x59bb45[_0xf578('0x5e')][_0xf578('0x91')]===_0xf578('0x61')){return _0x2ec91b[_0xf578('0x39')]({'read':!![]});}else{logger[_0xf578('0x26')](_0xf578('0x92'),_0xf578('0x2e'),_0xf578('0x8e'),util[_0xf578('0x8d')](_0x59bb45[_0xf578('0x5e')],{'showHidden':![],'depth':null}));}break;}return _0x2ec91b;}})[_0xf578('0x21')](respondWithResult(_0x447169,null))[_0xf578('0x59')](handleError(_0x447169,null));};
\ No newline at end of file
+var _0x1783=['catch','sendStatus','status','undefined','offset','limit','set','Content-Range','json','update','destroy','end','stack','name','send','index','map','WhatsappMessage','rawAttributes','fieldName','type','key','model','query','filters','attributes','fields','length','hasOwnProperty','nolimit','sort','pick','filter','where','merge','options','count','includeAll','include','show','params','keys','intersection','find','create','body','describe','whatsapp-interactions','accept','whatsapp','readAt','YYYY-MM-DD\x20HH:mm:ss','UserId','user','agent','get','WhatsappInteractionId','read1stAt','format','interaction','info','[WHATSAPPMESSAGE:ACCEPT]\x20id=%s\x20name=%s\x20role=%s\x20interaction=%s\x20body=%s','role','AcceptMessage','SELECT\x20*\x20FROM\x20cm_contacts\x20WHERE\x20id\x20=\x20','sequelize','Sequelize','SELECT','contact','fullname','interface','SIP/%s','channel','event','EventManager','acceptmessage','reject','WhatsappInteraction','[WHATSAPPMESSAGE:REJECT]\x20id=%s\x20name=%s\x20role=%s\x20interaction=%s\x20body=%s','null','RejectMessage','rejectMessage','ContactId','QueryTypes','User','email','motionChannel','WhatsppMessage,\x20%s,\x20%s,\x20%s','received\x20delivery\x20report\x20from','inspect','twilio','messageId','MessageStatus','WhatsappAccount,\x20%s,\x20%s,\x20%s','eml-format','zip-dir','fast-json-patch','request-promise','moment','bluebird','util','path','sox','to-csv','fs-extra','lodash','squel','crypto','jsforce','desk.js','querystring','papaparse','../../components/auth/service','../../components/parsers/qs','../../components/parsers/advancedSearch','../../config/license/hardware','../../config/logger','api','../../config/utils','../../config/environment','../../mysqldb','redis','localhost','socket.io-emitter','./whatsappMessage.socket','http','request','then','WhatsappMessage,\x20%s,\x20%s','request\x20sent','error','code','message','result'];(function(_0x4fd75e,_0x219e4a){var _0x5b6338=function(_0xf2969c){while(--_0xf2969c){_0x4fd75e['push'](_0x4fd75e['shift']());}};_0x5b6338(++_0x219e4a);}(_0x1783,0x16a));var _0x3178=function(_0x2f6260,_0x166e04){_0x2f6260=_0x2f6260-0x0;var _0x5a18b8=_0x1783[_0x2f6260];return _0x5a18b8;};'use strict';var emlformat=require(_0x3178('0x0'));var rimraf=require('rimraf');var zipdir=require(_0x3178('0x1'));var jsonpatch=require(_0x3178('0x2'));var rp=require(_0x3178('0x3'));var moment=require(_0x3178('0x4'));var BPromise=require(_0x3178('0x5'));var Mustache=require('mustache');var util=require(_0x3178('0x6'));var path=require(_0x3178('0x7'));var sox=require(_0x3178('0x8'));var csv=require(_0x3178('0x9'));var ejs=require('ejs');var fs=require('fs');var fs_extra=require(_0x3178('0xa'));var _=require(_0x3178('0xb'));var squel=require(_0x3178('0xc'));var crypto=require(_0x3178('0xd'));var jsforce=require(_0x3178('0xe'));var deskjs=require(_0x3178('0xf'));var toCsv=require('to-csv');var querystring=require(_0x3178('0x10'));var Papa=require(_0x3178('0x11'));var Redis=require('ioredis');var authService=require(_0x3178('0x12'));var qs=require(_0x3178('0x13'));var as=require(_0x3178('0x14'));var hardwareService=require(_0x3178('0x15'));var logger=require(_0x3178('0x16'))(_0x3178('0x17'));var utils=require(_0x3178('0x18'));var config=require(_0x3178('0x19'));var licenseUtil=require('../../config/license/util');var db=require(_0x3178('0x1a'))['db'];config[_0x3178('0x1b')]=_['defaults'](config[_0x3178('0x1b')],{'host':_0x3178('0x1c'),'port':0x18eb});var socket=require(_0x3178('0x1d'))(new Redis(config[_0x3178('0x1b')]));require(_0x3178('0x1e'))['register'](socket);var jayson=require('jayson/promise');var client=jayson['client'][_0x3178('0x1f')]({'port':0x232c});var client9002=jayson['client'][_0x3178('0x1f')]({'port':0x232a});function respondWithRpcPromise(_0x329f6e,_0x4a3e11,_0x3a4d84,_0x48cd99){return new BPromise(function(_0x4238f0,_0x477928){var _0x560642=_0x48cd99||client;return _0x560642[_0x3178('0x20')](_0x329f6e,_0x3a4d84)[_0x3178('0x21')](function(_0x1e2c8a){logger['info'](_0x3178('0x22'),_0x4a3e11,_0x3178('0x23'));logger['debug']('WhatsappMessage,\x20%s,\x20%s,\x20%s',_0x4a3e11,'request\x20sent',JSON['stringify'](_0x1e2c8a));if(_0x1e2c8a[_0x3178('0x24')]){if(_0x1e2c8a[_0x3178('0x24')][_0x3178('0x25')]===0x1f4){logger[_0x3178('0x24')]('WhatsappMessage,\x20%s,\x20%s',_0x4a3e11,_0x1e2c8a[_0x3178('0x24')]['message']);return _0x477928(_0x1e2c8a[_0x3178('0x24')][_0x3178('0x26')]);}logger[_0x3178('0x24')]('WhatsappMessage,\x20%s,\x20%s',_0x4a3e11,_0x1e2c8a['error'][_0x3178('0x26')]);return _0x4238f0(_0x1e2c8a[_0x3178('0x24')][_0x3178('0x26')]);}else{logger['info'](_0x3178('0x22'),_0x4a3e11,_0x3178('0x23'));_0x4238f0(_0x1e2c8a[_0x3178('0x27')][_0x3178('0x26')]);}})[_0x3178('0x28')](function(_0x30f7e6){logger[_0x3178('0x24')](_0x3178('0x22'),_0x4a3e11,_0x30f7e6);_0x477928(_0x30f7e6);});});}function respondWithStatusCode(_0x14b1cb,_0xc30828){_0xc30828=_0xc30828||0xcc;return function(_0x345cd7){if(_0x345cd7){return _0x14b1cb[_0x3178('0x29')](_0xc30828);}return _0x14b1cb[_0x3178('0x2a')](_0xc30828)['end']();};}function respondWithResult(_0x1d92e2,_0x4f90a0){_0x4f90a0=_0x4f90a0||0xc8;return function(_0x23b8a1){if(_0x23b8a1){return _0x1d92e2['status'](_0x4f90a0)['json'](_0x23b8a1);}};}function respondWithFilteredResult(_0x1056d4,_0x4706fe){return function(_0x4b1890){if(_0x4b1890){var _0x3d959e=typeof _0x4706fe['offset']==='undefined'&&typeof _0x4706fe['limit']===_0x3178('0x2b');var _0x47e85c=_0x4b1890['count'];var _0x25180f=_0x3d959e?0x0:_0x4706fe[_0x3178('0x2c')];var _0x1ce860=_0x3d959e?_0x4b1890['count']:_0x4706fe[_0x3178('0x2c')]+_0x4706fe[_0x3178('0x2d')];var _0x3fb501;if(_0x1ce860>=_0x47e85c){_0x1ce860=_0x47e85c;_0x3fb501=0xc8;}else{_0x3fb501=0xce;}_0x1056d4[_0x3178('0x2a')](_0x3fb501);return _0x1056d4[_0x3178('0x2e')](_0x3178('0x2f'),_0x25180f+'-'+_0x1ce860+'/'+_0x47e85c)[_0x3178('0x30')](_0x4b1890);}return null;};}function patchUpdates(_0x19a7c0){return function(_0xe7ce33){try{jsonpatch['apply'](_0xe7ce33,_0x19a7c0,!![]);}catch(_0x51af17){return BPromise['reject'](_0x51af17);}return _0xe7ce33['save']();};}function saveUpdates(_0x5cfabf,_0x18d870){return function(_0x2cc366){if(_0x2cc366){return _0x2cc366[_0x3178('0x31')](_0x5cfabf)[_0x3178('0x21')](function(_0x423261){return _0x423261;});}return null;};}function removeEntity(_0x436845,_0xfca770){return function(_0x4a2e6f){if(_0x4a2e6f){return _0x4a2e6f[_0x3178('0x32')]()[_0x3178('0x21')](function(){_0x436845['status'](0xcc)[_0x3178('0x33')]();});}};}function handleEntityNotFound(_0x2119e6,_0x24a26b){return function(_0x42d67d){if(!_0x42d67d){_0x2119e6[_0x3178('0x29')](0x194);}return _0x42d67d;};}function handleError(_0x585b3c,_0x59d63c){_0x59d63c=_0x59d63c||0x1f4;return function(_0x4fb49e){logger['error'](_0x4fb49e[_0x3178('0x34')]);if(_0x4fb49e[_0x3178('0x35')]){delete _0x4fb49e['name'];}_0x585b3c['status'](_0x59d63c)[_0x3178('0x36')](_0x4fb49e);};}exports[_0x3178('0x37')]=function(_0x40867d,_0x3c5e50){var _0x4378a5={},_0x385d94={},_0x42d138={'count':0x0,'rows':[]};var _0x26ced7=_[_0x3178('0x38')](db[_0x3178('0x39')][_0x3178('0x3a')],function(_0x40dc68){return{'name':_0x40dc68[_0x3178('0x3b')],'type':_0x40dc68[_0x3178('0x3c')][_0x3178('0x3d')]};});_0x385d94[_0x3178('0x3e')]=_['map'](_0x26ced7,_0x3178('0x35'));_0x385d94[_0x3178('0x3f')]=_['keys'](_0x40867d[_0x3178('0x3f')]);_0x385d94[_0x3178('0x40')]=_['intersection'](_0x385d94[_0x3178('0x3e')],_0x385d94['query']);_0x4378a5[_0x3178('0x41')]=_['intersection'](_0x385d94[_0x3178('0x3e')],qs[_0x3178('0x42')](_0x40867d['query']['fields']));_0x4378a5['attributes']=_0x4378a5[_0x3178('0x41')][_0x3178('0x43')]?_0x4378a5['attributes']:_0x385d94[_0x3178('0x3e')];if(!_0x40867d[_0x3178('0x3f')][_0x3178('0x44')](_0x3178('0x45'))){_0x4378a5[_0x3178('0x2d')]=qs['limit'](_0x40867d[_0x3178('0x3f')][_0x3178('0x2d')]);_0x4378a5[_0x3178('0x2c')]=qs[_0x3178('0x2c')](_0x40867d['query'][_0x3178('0x2c')]);}_0x4378a5['order']=qs['sort'](_0x40867d[_0x3178('0x3f')][_0x3178('0x46')]);_0x4378a5['where']=qs[_0x3178('0x40')](_[_0x3178('0x47')](_0x40867d[_0x3178('0x3f')],_0x385d94[_0x3178('0x40')]),_0x26ced7);if(_0x40867d[_0x3178('0x3f')][_0x3178('0x48')]){_0x4378a5[_0x3178('0x49')]=_[_0x3178('0x4a')](_0x4378a5['where'],{'$or':_[_0x3178('0x38')](_0x26ced7,function(_0x21d999){if(_0x21d999[_0x3178('0x3c')]!=='VIRTUAL'){var _0x21f4b3={};_0x21f4b3[_0x21d999[_0x3178('0x35')]]={'$like':'%'+_0x40867d[_0x3178('0x3f')][_0x3178('0x48')]+'%'};return _0x21f4b3;}})});}_0x4378a5=_['merge']({},_0x4378a5,_0x40867d[_0x3178('0x4b')]);var _0x97cef={'where':_0x4378a5['where']};return db['WhatsappMessage']['count'](_0x97cef)[_0x3178('0x21')](function(_0x2eb155){_0x42d138[_0x3178('0x4c')]=_0x2eb155;if(_0x40867d[_0x3178('0x3f')][_0x3178('0x4d')]){_0x4378a5[_0x3178('0x4e')]=[{'all':!![]}];}return db['WhatsappMessage']['findAll'](_0x4378a5);})['then'](function(_0x2b5c49){_0x42d138['rows']=_0x2b5c49;return _0x42d138;})[_0x3178('0x21')](respondWithFilteredResult(_0x3c5e50,_0x4378a5))['catch'](handleError(_0x3c5e50,null));};exports[_0x3178('0x4f')]=function(_0x4c0158,_0x47d9dd){var _0x41238a={'raw':!![],'where':{'id':_0x4c0158[_0x3178('0x50')]['id']}},_0x1f055a={};_0x1f055a[_0x3178('0x3e')]=_['keys'](db[_0x3178('0x39')][_0x3178('0x3a')]);_0x1f055a[_0x3178('0x3f')]=_[_0x3178('0x51')](_0x4c0158[_0x3178('0x3f')]);_0x1f055a[_0x3178('0x40')]=_[_0x3178('0x52')](_0x1f055a[_0x3178('0x3e')],_0x1f055a['query']);_0x41238a[_0x3178('0x41')]=_['intersection'](_0x1f055a[_0x3178('0x3e')],qs[_0x3178('0x42')](_0x4c0158[_0x3178('0x3f')][_0x3178('0x42')]));_0x41238a[_0x3178('0x41')]=_0x41238a[_0x3178('0x41')][_0x3178('0x43')]?_0x41238a[_0x3178('0x41')]:_0x1f055a[_0x3178('0x3e')];if(_0x4c0158[_0x3178('0x3f')]['includeAll']){_0x41238a[_0x3178('0x4e')]=[{'all':!![]}];}_0x41238a=_[_0x3178('0x4a')]({},_0x41238a,_0x4c0158['options']);return db[_0x3178('0x39')][_0x3178('0x53')](_0x41238a)[_0x3178('0x21')](handleEntityNotFound(_0x47d9dd,null))[_0x3178('0x21')](respondWithResult(_0x47d9dd,null))[_0x3178('0x28')](handleError(_0x47d9dd,null));};exports[_0x3178('0x54')]=function(_0x54d9c8,_0x1e6935){return db['WhatsappMessage'][_0x3178('0x54')](_0x54d9c8[_0x3178('0x55')],{})[_0x3178('0x21')](respondWithResult(_0x1e6935,0xc9))[_0x3178('0x28')](handleError(_0x1e6935,null));};exports[_0x3178('0x31')]=function(_0x3d6df5,_0x4e2760){if(_0x3d6df5['body']['id']){delete _0x3d6df5[_0x3178('0x55')]['id'];}return db[_0x3178('0x39')][_0x3178('0x53')]({'where':{'id':_0x3d6df5[_0x3178('0x50')]['id']}})[_0x3178('0x21')](handleEntityNotFound(_0x4e2760,null))['then'](saveUpdates(_0x3d6df5[_0x3178('0x55')],null))[_0x3178('0x21')](respondWithResult(_0x4e2760,null))[_0x3178('0x28')](handleError(_0x4e2760,null));};exports[_0x3178('0x32')]=function(_0x436013,_0x48e77e){return db[_0x3178('0x39')][_0x3178('0x53')]({'where':{'id':_0x436013[_0x3178('0x50')]['id']}})['then'](handleEntityNotFound(_0x48e77e,null))[_0x3178('0x21')](removeEntity(_0x48e77e,null))['catch'](handleError(_0x48e77e,null));};exports[_0x3178('0x56')]=function(_0x5a8e9a,_0xffe4e6){return db[_0x3178('0x39')]['describe']()[_0x3178('0x21')](respondWithResult(_0xffe4e6,null))[_0x3178('0x28')](handleError(_0xffe4e6,null));};var interaction_log=require(_0x3178('0x16'))(_0x3178('0x57'));exports[_0x3178('0x58')]=function(_0x5753a0,_0x239cbd,_0x3a6234){var _0x59a300={'agent':{},'channel':_0x3178('0x59')};if(_0x5753a0[_0x3178('0x55')]['id']){delete _0x5753a0[_0x3178('0x55')]['id'];}_0x5753a0[_0x3178('0x55')]['read']=!![];_0x5753a0[_0x3178('0x55')][_0x3178('0x5a')]=moment()['format'](_0x3178('0x5b'));_0x5753a0[_0x3178('0x55')][_0x3178('0x5c')]=_0x5753a0[_0x3178('0x55')]['UserId']||_0x5753a0[_0x3178('0x5d')]['id'];_0x59a300[_0x3178('0x5e')]['id']=_0x5753a0['body']['UserId'];return db[_0x3178('0x39')][_0x3178('0x53')]({'where':{'id':_0x5753a0[_0x3178('0x50')]['id'],'UserId':null}})[_0x3178('0x21')](handleEntityNotFound(_0x239cbd,null))['then'](saveUpdates(_0x5753a0[_0x3178('0x55')],null))[_0x3178('0x21')](function(_0x341bb9){if(_0x341bb9){_0x59a300[_0x3178('0x26')]=_0x341bb9[_0x3178('0x5f')]({'plain':!![]});return db['WhatsappInteraction'][_0x3178('0x53')]({'where':{'id':_0x341bb9[_0x3178('0x60')]}});}return null;})[_0x3178('0x21')](handleEntityNotFound(_0x239cbd,null))[_0x3178('0x21')](function(_0x9e17bd){if(_0x9e17bd){return _0x9e17bd[_0x3178('0x31')]({'UserId':_0x5753a0[_0x3178('0x55')][_0x3178('0x5c')],'read1stAt':_['isNil'](_0x9e17bd[_0x3178('0x61')])?moment()[_0x3178('0x62')](_0x3178('0x5b')):undefined});}return null;})['then'](function(_0x348bca){if(_0x348bca){_0x59a300[_0x3178('0x63')]=_0x348bca['get']({'plain':!![]});interaction_log[_0x3178('0x64')](_0x3178('0x65'),_0x5753a0[_0x3178('0x5d')]['id'],_0x5753a0['user']['name'],_0x5753a0['user'][_0x3178('0x66')],_0x59a300[_0x3178('0x63')]['id'],_0x5753a0[_0x3178('0x55')]?JSON['stringify'](_0x5753a0[_0x3178('0x55')]):'null');return respondWithRpcPromise(_0x3178('0x67'),'acceptMessage',_0x59a300);}return null;})[_0x3178('0x21')](function(_0x3828c2){var _0x3c7161=_0x3178('0x68')+_0x3828c2[_0x3178('0x26')]['ContactId'];return db[_0x3178('0x69')][_0x3178('0x3f')](_0x3c7161,{'type':db[_0x3178('0x6a')]['QueryTypes'][_0x3178('0x6b')],'raw':!![]})[_0x3178('0x21')](function(_0x151eaa){return _0x151eaa;});})[_0x3178('0x21')](function(_0x385700){if(_0x385700){_0x59a300['message'][_0x3178('0x6c')]=_0x385700[0x0];if(!_0x5753a0['body'][_0x3178('0x5c')])return;return db['User']['find']({'where':{'id':_0x5753a0[_0x3178('0x55')]['UserId'],'role':_0x3178('0x5e')},'attributes':['id',_0x3178('0x35'),_0x3178('0x6d'),'email','internal'],'raw':!![]});}return null;})[_0x3178('0x21')](function(_0x273508){if(!_0x273508)return null;_0x59a300[_0x3178('0x26')][_0x3178('0x5e')]=_0x273508;return _0x59a300;})[_0x3178('0x21')](function(_0x3a1c08){if(_0x3a1c08){if(_0x5753a0[_0x3178('0x55')]['manual']){_0x59a300[_0x3178('0x26')][_0x3178('0x6e')]=util['format'](_0x3178('0x6f'),_0x5753a0[_0x3178('0x5d')]['name']);_0x59a300['message'][_0x3178('0x70')]=_0x59a300[_0x3178('0x70')];_0x59a300['message']['motionChannel']=_0x59a300[_0x3178('0x70')];_0x59a300[_0x3178('0x26')][_0x3178('0x71')]=_0x3178('0x58');return respondWithRpcPromise(_0x3178('0x72'),_0x3178('0x72'),{'event':_0x3178('0x73'),'message':_0x59a300[_0x3178('0x26')]},client9002)[_0x3178('0x21')](function(){return _0x59a300;});}return _0x59a300;}return null;})[_0x3178('0x21')](respondWithResult(_0x239cbd,null))[_0x3178('0x28')](handleError(_0x239cbd,null));};var interaction_log=require('../../config/logger')(_0x3178('0x57'));exports[_0x3178('0x74')]=function(_0x4134ff,_0x3ba13e,_0x15d174){var _0x37519b={'agent':{},'channel':_0x3178('0x59')};if(_0x4134ff[_0x3178('0x55')]['id']){delete _0x4134ff['body']['id'];}_0x4134ff[_0x3178('0x55')][_0x3178('0x5c')]=_0x4134ff[_0x3178('0x55')][_0x3178('0x5c')]||_0x4134ff[_0x3178('0x5d')]['id'];_0x37519b[_0x3178('0x5e')]['id']=_0x4134ff[_0x3178('0x55')][_0x3178('0x5c')];return db[_0x3178('0x39')][_0x3178('0x53')]({'where':{'id':_0x4134ff[_0x3178('0x50')]['id'],'UserId':null}})[_0x3178('0x21')](handleEntityNotFound(_0x3ba13e,null))[_0x3178('0x21')](function(_0x501e35){if(_0x501e35){_0x37519b['message']=_0x501e35[_0x3178('0x5f')]({'plain':!![]});return db[_0x3178('0x75')][_0x3178('0x53')]({'where':{'id':_0x501e35[_0x3178('0x60')]}});}return null;})[_0x3178('0x21')](handleEntityNotFound(_0x3ba13e,null))[_0x3178('0x21')](function(_0x5de5b1){if(_0x5de5b1){_0x37519b[_0x3178('0x63')]=_0x5de5b1[_0x3178('0x5f')]({'plain':!![]});interaction_log[_0x3178('0x64')](_0x3178('0x76'),_0x4134ff[_0x3178('0x5d')]['id'],_0x4134ff['user'][_0x3178('0x35')],_0x4134ff[_0x3178('0x5d')][_0x3178('0x66')],_0x37519b[_0x3178('0x63')]['id'],_0x4134ff[_0x3178('0x55')]?JSON['stringify'](_0x4134ff[_0x3178('0x55')]):_0x3178('0x77'));return respondWithRpcPromise(_0x3178('0x78'),_0x3178('0x79'),_0x37519b);}return null;})[_0x3178('0x21')](function(_0x57b5a0){var _0x56ca2d=_0x3178('0x68')+_0x57b5a0['message'][_0x3178('0x7a')];return db[_0x3178('0x69')][_0x3178('0x3f')](_0x56ca2d,{'type':db['Sequelize'][_0x3178('0x7b')]['SELECT'],'raw':!![]})[_0x3178('0x21')](function(_0x513bfa){return _0x513bfa;});})[_0x3178('0x21')](function(_0x4d0a6b){if(_0x4d0a6b){_0x37519b['message'][_0x3178('0x6c')]=_0x4d0a6b[0x0];if(!_0x4134ff['body'][_0x3178('0x5c')])return;return db[_0x3178('0x7c')][_0x3178('0x53')]({'where':{'id':_0x4134ff['body']['UserId'],'role':_0x3178('0x5e')},'attributes':['id',_0x3178('0x35'),_0x3178('0x6d'),_0x3178('0x7d'),'internal'],'raw':!![]});}return null;})[_0x3178('0x21')](function(_0x565b70){if(!_0x565b70)return null;_0x37519b['message'][_0x3178('0x5e')]=_0x565b70;return _0x37519b;})[_0x3178('0x21')](function(_0x2fbbfb){if(_0x2fbbfb){_0x2fbbfb['message']['interface']=util[_0x3178('0x62')]('SIP/%s',_0x4134ff[_0x3178('0x5d')][_0x3178('0x35')]);_0x2fbbfb[_0x3178('0x26')][_0x3178('0x70')]=_0x37519b[_0x3178('0x70')];_0x2fbbfb[_0x3178('0x26')][_0x3178('0x7e')]=_0x37519b[_0x3178('0x70')];_0x2fbbfb[_0x3178('0x26')][_0x3178('0x71')]='reject';respondWithRpcPromise('EventManager',_0x3178('0x72'),{'event':'rejectmessage','message':_0x2fbbfb[_0x3178('0x26')]},client9002);return _0x37519b;}return null;})[_0x3178('0x21')](respondWithResult(_0x3ba13e,null))[_0x3178('0x28')](handleError(_0x3ba13e,null));};exports[_0x3178('0x2a')]=function(_0x225ad3,_0x18b729,_0x48ee7b){if(_0x225ad3['body']['id']){delete _0x225ad3[_0x3178('0x55')]['id'];}var _0x16b38f;return db['WhatsappMessage'][_0x3178('0x53')]({'where':{'id':_0x225ad3[_0x3178('0x50')]['id']}})[_0x3178('0x21')](handleEntityNotFound(_0x18b729,null))[_0x3178('0x21')](function(_0x67a4ff){if(_0x67a4ff){_0x16b38f=_0x67a4ff;return db['WhatsappAccount'][_0x3178('0x53')]({'where':{'id':_0x67a4ff['WhatsappAccountId']}});}})[_0x3178('0x21')](handleEntityNotFound(_0x18b729,null))[_0x3178('0x21')](function(_0x2e8b8d){if(_0x2e8b8d){logger['debug'](_0x3178('0x7f'),'status',_0x3178('0x80'),_0x2e8b8d['type'],util[_0x3178('0x81')](_0x225ad3['body'],{'showHidden':![],'depth':null}));switch(_0x2e8b8d[_0x3178('0x3c')]){case _0x3178('0x82'):if(_0x225ad3[_0x3178('0x55')]['MessageSid']&&_0x225ad3[_0x3178('0x55')]['MessageSid']===_0x16b38f[_0x3178('0x83')]&&_0x225ad3['body'][_0x3178('0x84')]&&_0x225ad3[_0x3178('0x55')]['MessageStatus']==='read'){return _0x16b38f[_0x3178('0x31')]({'read':!![]});}else{logger[_0x3178('0x24')](_0x3178('0x85'),_0x3178('0x2a'),_0x3178('0x82'),util[_0x3178('0x81')](_0x225ad3['body'],{'showHidden':![],'depth':null}));}break;}return _0x16b38f;}})[_0x3178('0x21')](respondWithResult(_0x18b729,null))[_0x3178('0x28')](handleError(_0x18b729,null));};
\ No newline at end of file