Built motion from commit f25620e4.|2.6.30
[motion2.git] / server / api / whatsappMessage / whatsappMessage.controller.js
index ed1ad1a..91778c9 100644 (file)
@@ -15,4 +15,4 @@
 // * treaties. The SOFTWARE PRODUCT is licensed, not sold.                        *
 // *                                                                       *
 // *************************************************************************
-var _0x242f=['WhatsappMessage,\x20%s,\x20%s,\x20%s','stringify','error','code','WhatsappMessage,\x20%s,\x20%s','message','catch','sendStatus','end','json','undefined','limit','count','offset','set','Content-Range','reject','stack','name','send','index','map','WhatsappMessage','rawAttributes','fieldName','type','key','model','query','filters','intersection','fields','attributes','length','hasOwnProperty','nolimit','order','sort','where','pick','filter','merge','options','includeAll','include','findAll','show','params','keys','create','body','find','destroy','describe','../../config/logger','whatsapp-interactions','accept','whatsapp','read','readAt','format','YYYY-MM-DD\x20HH:mm:ss','UserId','user','agent','get','WhatsappInteraction','WhatsappInteractionId','isNil','interaction','[WHATSAPPMESSAGE:ACCEPT]\x20id=%s\x20name=%s\x20role=%s\x20interaction=%s\x20body=%s','null','AcceptMessage','acceptMessage','sequelize','Sequelize','QueryTypes','SELECT','contact','User','email','internal','manual','SIP/%s','channel','motionChannel','EventManager','acceptmessage','[WHATSAPPMESSAGE:REJECT]\x20id=%s\x20name=%s\x20role=%s\x20interaction=%s\x20body=%s','role','RejectMessage','rejectMessage','SELECT\x20*\x20FROM\x20cm_contacts\x20WHERE\x20id\x20=\x20','ContactId','fullname','interface','event','rejectmessage','WhatsappAccount','WhatsappAccountId','WhatsppMessage,\x20%s,\x20%s,\x20%s','status','received\x20delivery\x20report\x20from','twilio','MessageSid','messageId','MessageStatus','WhatsappAccount,\x20%s,\x20%s,\x20%s','inspect','eml-format','zip-dir','fast-json-patch','request-promise','moment','mustache','util','sox','fs-extra','squel','crypto','jsforce','desk.js','to-csv','querystring','papaparse','ioredis','../../components/auth/service','../../components/parsers/qs','../../components/parsers/advancedSearch','../../config/license/hardware','../../config/utils','../../config/environment','../../config/license/util','../../mysqldb','redis','defaults','localhost','socket.io-emitter','./whatsappMessage.socket','register','jayson/promise','http','client','then','info','request\x20sent','debug'];(function(_0x3ce3d0,_0x597f99){var _0x23cbe9=function(_0x5dd39b){while(--_0x5dd39b){_0x3ce3d0['push'](_0x3ce3d0['shift']());}};_0x23cbe9(++_0x597f99);}(_0x242f,0x6d));var _0xf242=function(_0xba7840,_0x36fac8){_0xba7840=_0xba7840-0x0;var _0x532b9a=_0x242f[_0xba7840];return _0x532b9a;};'use strict';var emlformat=require(_0xf242('0x0'));var rimraf=require('rimraf');var zipdir=require(_0xf242('0x1'));var jsonpatch=require(_0xf242('0x2'));var rp=require(_0xf242('0x3'));var moment=require(_0xf242('0x4'));var BPromise=require('bluebird');var Mustache=require(_0xf242('0x5'));var util=require(_0xf242('0x6'));var path=require('path');var sox=require(_0xf242('0x7'));var csv=require('to-csv');var ejs=require('ejs');var fs=require('fs');var fs_extra=require(_0xf242('0x8'));var _=require('lodash');var squel=require(_0xf242('0x9'));var crypto=require(_0xf242('0xa'));var jsforce=require(_0xf242('0xb'));var deskjs=require(_0xf242('0xc'));var toCsv=require(_0xf242('0xd'));var querystring=require(_0xf242('0xe'));var Papa=require(_0xf242('0xf'));var Redis=require(_0xf242('0x10'));var authService=require(_0xf242('0x11'));var qs=require(_0xf242('0x12'));var as=require(_0xf242('0x13'));var hardwareService=require(_0xf242('0x14'));var logger=require('../../config/logger')('api');var utils=require(_0xf242('0x15'));var config=require(_0xf242('0x16'));var licenseUtil=require(_0xf242('0x17'));var db=require(_0xf242('0x18'))['db'];config[_0xf242('0x19')]=_[_0xf242('0x1a')](config['redis'],{'host':_0xf242('0x1b'),'port':0x18eb});var socket=require(_0xf242('0x1c'))(new Redis(config[_0xf242('0x19')]));require(_0xf242('0x1d'))[_0xf242('0x1e')](socket);var jayson=require(_0xf242('0x1f'));var client=jayson['client'][_0xf242('0x20')]({'port':0x232c});var client9002=jayson[_0xf242('0x21')]['http']({'port':0x232a});function respondWithRpcPromise(_0x53eeb4,_0x470548,_0x406158,_0x4abbed){return new BPromise(function(_0x1975c7,_0x5409c6){var _0x5f195b=_0x4abbed||client;return _0x5f195b['request'](_0x53eeb4,_0x406158)[_0xf242('0x22')](function(_0x417bed){logger[_0xf242('0x23')]('WhatsappMessage,\x20%s,\x20%s',_0x470548,_0xf242('0x24'));logger[_0xf242('0x25')](_0xf242('0x26'),_0x470548,_0xf242('0x24'),JSON[_0xf242('0x27')](_0x417bed));if(_0x417bed[_0xf242('0x28')]){if(_0x417bed[_0xf242('0x28')][_0xf242('0x29')]===0x1f4){logger[_0xf242('0x28')](_0xf242('0x2a'),_0x470548,_0x417bed[_0xf242('0x28')][_0xf242('0x2b')]);return _0x5409c6(_0x417bed[_0xf242('0x28')][_0xf242('0x2b')]);}logger[_0xf242('0x28')](_0xf242('0x2a'),_0x470548,_0x417bed[_0xf242('0x28')][_0xf242('0x2b')]);return _0x1975c7(_0x417bed[_0xf242('0x28')][_0xf242('0x2b')]);}else{logger[_0xf242('0x23')](_0xf242('0x2a'),_0x470548,_0xf242('0x24'));_0x1975c7(_0x417bed['result'][_0xf242('0x2b')]);}})[_0xf242('0x2c')](function(_0x421140){logger[_0xf242('0x28')](_0xf242('0x2a'),_0x470548,_0x421140);_0x5409c6(_0x421140);});});}function respondWithStatusCode(_0x20df5f,_0x434b07){_0x434b07=_0x434b07||0xcc;return function(_0x1710ba){if(_0x1710ba){return _0x20df5f[_0xf242('0x2d')](_0x434b07);}return _0x20df5f['status'](_0x434b07)[_0xf242('0x2e')]();};}function respondWithResult(_0x1b3eab,_0x477c24){_0x477c24=_0x477c24||0xc8;return function(_0x33a891){if(_0x33a891){return _0x1b3eab['status'](_0x477c24)[_0xf242('0x2f')](_0x33a891);}};}function respondWithFilteredResult(_0xfe68ff,_0x240648){return function(_0x33afdd){if(_0x33afdd){var _0x296702=typeof _0x240648['offset']===_0xf242('0x30')&&typeof _0x240648[_0xf242('0x31')]==='undefined';var _0x4617f9=_0x33afdd[_0xf242('0x32')];var _0x4f5ad0=_0x296702?0x0:_0x240648[_0xf242('0x33')];var _0x2d4c77=_0x296702?_0x33afdd[_0xf242('0x32')]:_0x240648['offset']+_0x240648[_0xf242('0x31')];var _0x2039e9;if(_0x2d4c77>=_0x4617f9){_0x2d4c77=_0x4617f9;_0x2039e9=0xc8;}else{_0x2039e9=0xce;}_0xfe68ff['status'](_0x2039e9);return _0xfe68ff[_0xf242('0x34')](_0xf242('0x35'),_0x4f5ad0+'-'+_0x2d4c77+'/'+_0x4617f9)[_0xf242('0x2f')](_0x33afdd);}return null;};}function patchUpdates(_0x4d1777){return function(_0x1076c9){try{jsonpatch['apply'](_0x1076c9,_0x4d1777,!![]);}catch(_0x81d328){return BPromise[_0xf242('0x36')](_0x81d328);}return _0x1076c9['save']();};}function saveUpdates(_0x498829,_0x4dc597){return function(_0x186575){if(_0x186575){return _0x186575['update'](_0x498829)['then'](function(_0x587282){return _0x587282;});}return null;};}function removeEntity(_0x525d96,_0x377d3e){return function(_0x1e2bf2){if(_0x1e2bf2){return _0x1e2bf2['destroy']()[_0xf242('0x22')](function(){_0x525d96['status'](0xcc)[_0xf242('0x2e')]();});}};}function handleEntityNotFound(_0x30c4b1,_0x238239){return function(_0xd127af){if(!_0xd127af){_0x30c4b1[_0xf242('0x2d')](0x194);}return _0xd127af;};}function handleError(_0x35e837,_0x5bc530){_0x5bc530=_0x5bc530||0x1f4;return function(_0x302e7d){logger['error'](_0x302e7d[_0xf242('0x37')]);if(_0x302e7d['name']){delete _0x302e7d[_0xf242('0x38')];}_0x35e837['status'](_0x5bc530)[_0xf242('0x39')](_0x302e7d);};}exports[_0xf242('0x3a')]=function(_0x4074dc,_0x1b1c84){var _0x1bfc34={},_0x150a39={},_0x28cf02={'count':0x0,'rows':[]};var _0xf904e=_[_0xf242('0x3b')](db[_0xf242('0x3c')][_0xf242('0x3d')],function(_0x670a42){return{'name':_0x670a42[_0xf242('0x3e')],'type':_0x670a42[_0xf242('0x3f')][_0xf242('0x40')]};});_0x150a39[_0xf242('0x41')]=_[_0xf242('0x3b')](_0xf904e,'name');_0x150a39[_0xf242('0x42')]=_['keys'](_0x4074dc[_0xf242('0x42')]);_0x150a39[_0xf242('0x43')]=_[_0xf242('0x44')](_0x150a39['model'],_0x150a39[_0xf242('0x42')]);_0x1bfc34['attributes']=_[_0xf242('0x44')](_0x150a39[_0xf242('0x41')],qs[_0xf242('0x45')](_0x4074dc[_0xf242('0x42')][_0xf242('0x45')]));_0x1bfc34[_0xf242('0x46')]=_0x1bfc34[_0xf242('0x46')][_0xf242('0x47')]?_0x1bfc34['attributes']:_0x150a39[_0xf242('0x41')];if(!_0x4074dc[_0xf242('0x42')][_0xf242('0x48')](_0xf242('0x49'))){_0x1bfc34[_0xf242('0x31')]=qs['limit'](_0x4074dc[_0xf242('0x42')][_0xf242('0x31')]);_0x1bfc34['offset']=qs['offset'](_0x4074dc[_0xf242('0x42')]['offset']);}_0x1bfc34[_0xf242('0x4a')]=qs[_0xf242('0x4b')](_0x4074dc[_0xf242('0x42')][_0xf242('0x4b')]);_0x1bfc34[_0xf242('0x4c')]=qs[_0xf242('0x43')](_[_0xf242('0x4d')](_0x4074dc[_0xf242('0x42')],_0x150a39[_0xf242('0x43')]),_0xf904e);if(_0x4074dc[_0xf242('0x42')][_0xf242('0x4e')]){_0x1bfc34[_0xf242('0x4c')]=_[_0xf242('0x4f')](_0x1bfc34[_0xf242('0x4c')],{'$or':_[_0xf242('0x3b')](_0xf904e,function(_0x503682){if(_0x503682[_0xf242('0x3f')]!=='VIRTUAL'){var _0x280e3b={};_0x280e3b[_0x503682[_0xf242('0x38')]]={'$like':'%'+_0x4074dc['query'][_0xf242('0x4e')]+'%'};return _0x280e3b;}})});}_0x1bfc34=_['merge']({},_0x1bfc34,_0x4074dc[_0xf242('0x50')]);var _0x4c998e={'where':_0x1bfc34[_0xf242('0x4c')]};return db[_0xf242('0x3c')][_0xf242('0x32')](_0x4c998e)[_0xf242('0x22')](function(_0xb9ebb3){_0x28cf02[_0xf242('0x32')]=_0xb9ebb3;if(_0x4074dc[_0xf242('0x42')][_0xf242('0x51')]){_0x1bfc34[_0xf242('0x52')]=[{'all':!![]}];}return db['WhatsappMessage'][_0xf242('0x53')](_0x1bfc34);})[_0xf242('0x22')](function(_0x3240c7){_0x28cf02['rows']=_0x3240c7;return _0x28cf02;})['then'](respondWithFilteredResult(_0x1b1c84,_0x1bfc34))['catch'](handleError(_0x1b1c84,null));};exports[_0xf242('0x54')]=function(_0x48a035,_0xf79a1){var _0x2425e4={'raw':!![],'where':{'id':_0x48a035[_0xf242('0x55')]['id']}},_0x4ef93e={};_0x4ef93e[_0xf242('0x41')]=_[_0xf242('0x56')](db[_0xf242('0x3c')]['rawAttributes']);_0x4ef93e[_0xf242('0x42')]=_[_0xf242('0x56')](_0x48a035[_0xf242('0x42')]);_0x4ef93e[_0xf242('0x43')]=_[_0xf242('0x44')](_0x4ef93e[_0xf242('0x41')],_0x4ef93e['query']);_0x2425e4[_0xf242('0x46')]=_['intersection'](_0x4ef93e['model'],qs['fields'](_0x48a035[_0xf242('0x42')][_0xf242('0x45')]));_0x2425e4[_0xf242('0x46')]=_0x2425e4[_0xf242('0x46')][_0xf242('0x47')]?_0x2425e4['attributes']:_0x4ef93e[_0xf242('0x41')];if(_0x48a035['query'][_0xf242('0x51')]){_0x2425e4[_0xf242('0x52')]=[{'all':!![]}];}_0x2425e4=_['merge']({},_0x2425e4,_0x48a035['options']);return db[_0xf242('0x3c')]['find'](_0x2425e4)['then'](handleEntityNotFound(_0xf79a1,null))[_0xf242('0x22')](respondWithResult(_0xf79a1,null))[_0xf242('0x2c')](handleError(_0xf79a1,null));};exports['create']=function(_0x2c8e5d,_0x54c411){return db[_0xf242('0x3c')][_0xf242('0x57')](_0x2c8e5d[_0xf242('0x58')],{})[_0xf242('0x22')](respondWithResult(_0x54c411,0xc9))[_0xf242('0x2c')](handleError(_0x54c411,null));};exports['update']=function(_0x496f62,_0x1967ed){if(_0x496f62[_0xf242('0x58')]['id']){delete _0x496f62[_0xf242('0x58')]['id'];}return db[_0xf242('0x3c')][_0xf242('0x59')]({'where':{'id':_0x496f62[_0xf242('0x55')]['id']}})['then'](handleEntityNotFound(_0x1967ed,null))['then'](saveUpdates(_0x496f62['body'],null))[_0xf242('0x22')](respondWithResult(_0x1967ed,null))['catch'](handleError(_0x1967ed,null));};exports[_0xf242('0x5a')]=function(_0x2b9132,_0x4de1b9){return db[_0xf242('0x3c')][_0xf242('0x59')]({'where':{'id':_0x2b9132[_0xf242('0x55')]['id']}})[_0xf242('0x22')](handleEntityNotFound(_0x4de1b9,null))[_0xf242('0x22')](removeEntity(_0x4de1b9,null))[_0xf242('0x2c')](handleError(_0x4de1b9,null));};exports[_0xf242('0x5b')]=function(_0x5d0c1,_0x42580a){return db[_0xf242('0x3c')]['describe']()['then'](respondWithResult(_0x42580a,null))[_0xf242('0x2c')](handleError(_0x42580a,null));};var interaction_log=require(_0xf242('0x5c'))(_0xf242('0x5d'));exports[_0xf242('0x5e')]=function(_0x48b657,_0x287bad,_0x54be1f){var _0x27efd9={'agent':{},'channel':_0xf242('0x5f')};if(_0x48b657[_0xf242('0x58')]['id']){delete _0x48b657[_0xf242('0x58')]['id'];}_0x48b657[_0xf242('0x58')][_0xf242('0x60')]=!![];_0x48b657[_0xf242('0x58')][_0xf242('0x61')]=moment()[_0xf242('0x62')](_0xf242('0x63'));_0x48b657[_0xf242('0x58')][_0xf242('0x64')]=_0x48b657[_0xf242('0x58')][_0xf242('0x64')]||_0x48b657[_0xf242('0x65')]['id'];_0x27efd9[_0xf242('0x66')]['id']=_0x48b657[_0xf242('0x58')][_0xf242('0x64')];return db[_0xf242('0x3c')][_0xf242('0x59')]({'where':{'id':_0x48b657[_0xf242('0x55')]['id'],'UserId':null}})[_0xf242('0x22')](handleEntityNotFound(_0x287bad,null))['then'](saveUpdates(_0x48b657[_0xf242('0x58')],null))[_0xf242('0x22')](function(_0x3656e1){if(_0x3656e1){_0x27efd9[_0xf242('0x2b')]=_0x3656e1[_0xf242('0x67')]({'plain':!![]});return db[_0xf242('0x68')][_0xf242('0x59')]({'where':{'id':_0x3656e1[_0xf242('0x69')]}});}return null;})[_0xf242('0x22')](handleEntityNotFound(_0x287bad,null))[_0xf242('0x22')](function(_0x110ac8){if(_0x110ac8){return _0x110ac8['update']({'UserId':_0x48b657[_0xf242('0x58')][_0xf242('0x64')],'read1stAt':_[_0xf242('0x6a')](_0x110ac8['read1stAt'])?moment()[_0xf242('0x62')](_0xf242('0x63')):undefined});}return null;})['then'](function(_0x179b88){if(_0x179b88){_0x27efd9[_0xf242('0x6b')]=_0x179b88[_0xf242('0x67')]({'plain':!![]});interaction_log[_0xf242('0x23')](_0xf242('0x6c'),_0x48b657[_0xf242('0x65')]['id'],_0x48b657[_0xf242('0x65')][_0xf242('0x38')],_0x48b657[_0xf242('0x65')]['role'],_0x27efd9[_0xf242('0x6b')]['id'],_0x48b657[_0xf242('0x58')]?JSON[_0xf242('0x27')](_0x48b657[_0xf242('0x58')]):_0xf242('0x6d'));return respondWithRpcPromise(_0xf242('0x6e'),_0xf242('0x6f'),_0x27efd9);}return null;})['then'](function(_0x1110b2){var _0x3f7256='SELECT\x20*\x20FROM\x20cm_contacts\x20WHERE\x20id\x20=\x20'+_0x1110b2[_0xf242('0x2b')]['ContactId'];return db[_0xf242('0x70')][_0xf242('0x42')](_0x3f7256,{'type':db[_0xf242('0x71')][_0xf242('0x72')][_0xf242('0x73')],'raw':!![]})[_0xf242('0x22')](function(_0x1b9dc8){return _0x1b9dc8;});})[_0xf242('0x22')](function(_0x1f5d90){if(_0x1f5d90){_0x27efd9[_0xf242('0x2b')][_0xf242('0x74')]=_0x1f5d90[0x0];if(!_0x48b657[_0xf242('0x58')][_0xf242('0x64')])return;return db[_0xf242('0x75')][_0xf242('0x59')]({'where':{'id':_0x48b657[_0xf242('0x58')]['UserId'],'role':_0xf242('0x66')},'attributes':['id',_0xf242('0x38'),'fullname',_0xf242('0x76'),_0xf242('0x77')],'raw':!![]});}return null;})[_0xf242('0x22')](function(_0x2df131){if(!_0x2df131)return null;_0x27efd9['message']['agent']=_0x2df131;return _0x27efd9;})[_0xf242('0x22')](function(_0x5bf203){if(_0x5bf203){if(_0x48b657[_0xf242('0x58')][_0xf242('0x78')]){_0x27efd9['message']['interface']=util['format'](_0xf242('0x79'),_0x48b657[_0xf242('0x65')][_0xf242('0x38')]);_0x27efd9[_0xf242('0x2b')][_0xf242('0x7a')]=_0x27efd9[_0xf242('0x7a')];_0x27efd9[_0xf242('0x2b')][_0xf242('0x7b')]=_0x27efd9[_0xf242('0x7a')];_0x27efd9['message']['event']=_0xf242('0x5e');return respondWithRpcPromise('EventManager',_0xf242('0x7c'),{'event':_0xf242('0x7d'),'message':_0x27efd9[_0xf242('0x2b')]},client9002)['then'](function(){return _0x27efd9;});}return _0x27efd9;}return null;})['then'](respondWithResult(_0x287bad,null))[_0xf242('0x2c')](handleError(_0x287bad,null));};var interaction_log=require('../../config/logger')(_0xf242('0x5d'));exports[_0xf242('0x36')]=function(_0x59c0ed,_0x40a243,_0xcab383){var _0x1df906={'agent':{},'channel':_0xf242('0x5f')};if(_0x59c0ed['body']['id']){delete _0x59c0ed[_0xf242('0x58')]['id'];}_0x59c0ed[_0xf242('0x58')][_0xf242('0x64')]=_0x59c0ed[_0xf242('0x58')][_0xf242('0x64')]||_0x59c0ed[_0xf242('0x65')]['id'];_0x1df906[_0xf242('0x66')]['id']=_0x59c0ed[_0xf242('0x58')][_0xf242('0x64')];return db['WhatsappMessage'][_0xf242('0x59')]({'where':{'id':_0x59c0ed[_0xf242('0x55')]['id'],'UserId':null}})['then'](handleEntityNotFound(_0x40a243,null))[_0xf242('0x22')](function(_0x4ce10c){if(_0x4ce10c){_0x1df906['message']=_0x4ce10c['get']({'plain':!![]});return db['WhatsappInteraction'][_0xf242('0x59')]({'where':{'id':_0x4ce10c[_0xf242('0x69')]}});}return null;})['then'](handleEntityNotFound(_0x40a243,null))[_0xf242('0x22')](function(_0x501c76){if(_0x501c76){_0x1df906[_0xf242('0x6b')]=_0x501c76[_0xf242('0x67')]({'plain':!![]});interaction_log[_0xf242('0x23')](_0xf242('0x7e'),_0x59c0ed[_0xf242('0x65')]['id'],_0x59c0ed[_0xf242('0x65')][_0xf242('0x38')],_0x59c0ed['user'][_0xf242('0x7f')],_0x1df906['interaction']['id'],_0x59c0ed[_0xf242('0x58')]?JSON['stringify'](_0x59c0ed[_0xf242('0x58')]):_0xf242('0x6d'));return respondWithRpcPromise(_0xf242('0x80'),_0xf242('0x81'),_0x1df906);}return null;})['then'](function(_0x4949f2){var _0x3d38dc=_0xf242('0x82')+_0x4949f2['message'][_0xf242('0x83')];return db['sequelize'][_0xf242('0x42')](_0x3d38dc,{'type':db[_0xf242('0x71')][_0xf242('0x72')][_0xf242('0x73')],'raw':!![]})[_0xf242('0x22')](function(_0x324974){return _0x324974;});})['then'](function(_0x5927d9){if(_0x5927d9){_0x1df906[_0xf242('0x2b')]['contact']=_0x5927d9[0x0];if(!_0x59c0ed[_0xf242('0x58')][_0xf242('0x64')])return;return db[_0xf242('0x75')]['find']({'where':{'id':_0x59c0ed[_0xf242('0x58')][_0xf242('0x64')],'role':_0xf242('0x66')},'attributes':['id',_0xf242('0x38'),_0xf242('0x84'),_0xf242('0x76'),'internal'],'raw':!![]});}return null;})[_0xf242('0x22')](function(_0x4f3b7c){if(!_0x4f3b7c)return null;_0x1df906[_0xf242('0x2b')][_0xf242('0x66')]=_0x4f3b7c;return _0x1df906;})['then'](function(_0x5eeb75){if(_0x5eeb75){_0x5eeb75[_0xf242('0x2b')][_0xf242('0x85')]=util[_0xf242('0x62')](_0xf242('0x79'),_0x59c0ed['user'][_0xf242('0x38')]);_0x5eeb75['message'][_0xf242('0x7a')]=_0x1df906['channel'];_0x5eeb75[_0xf242('0x2b')][_0xf242('0x7b')]=_0x1df906[_0xf242('0x7a')];_0x5eeb75[_0xf242('0x2b')][_0xf242('0x86')]=_0xf242('0x36');respondWithRpcPromise(_0xf242('0x7c'),'EventManager',{'event':_0xf242('0x87'),'message':_0x5eeb75[_0xf242('0x2b')]},client9002);return _0x1df906;}return null;})[_0xf242('0x22')](respondWithResult(_0x40a243,null))[_0xf242('0x2c')](handleError(_0x40a243,null));};exports['status']=function(_0x3c678a,_0x16308e,_0x3494f4){if(_0x3c678a[_0xf242('0x58')]['id']){delete _0x3c678a['body']['id'];}var _0x3d5fa5;return db[_0xf242('0x3c')][_0xf242('0x59')]({'where':{'id':_0x3c678a[_0xf242('0x55')]['id']}})[_0xf242('0x22')](handleEntityNotFound(_0x16308e,null))[_0xf242('0x22')](function(_0x2215ff){if(_0x2215ff){_0x3d5fa5=_0x2215ff;return db[_0xf242('0x88')][_0xf242('0x59')]({'where':{'id':_0x2215ff[_0xf242('0x89')]}});}})[_0xf242('0x22')](handleEntityNotFound(_0x16308e,null))[_0xf242('0x22')](function(_0x463db0){if(_0x463db0){logger['debug'](_0xf242('0x8a'),_0xf242('0x8b'),_0xf242('0x8c'),_0x463db0['type'],util['inspect'](_0x3c678a[_0xf242('0x58')],{'showHidden':![],'depth':null}));switch(_0x463db0[_0xf242('0x3f')]){case _0xf242('0x8d'):if(_0x3c678a[_0xf242('0x58')][_0xf242('0x8e')]&&_0x3c678a['body'][_0xf242('0x8e')]===_0x3d5fa5[_0xf242('0x8f')]&&_0x3c678a[_0xf242('0x58')][_0xf242('0x90')]&&_0x3c678a[_0xf242('0x58')][_0xf242('0x90')]===_0xf242('0x60')){return _0x3d5fa5['update']({'read':!![]});}else{logger[_0xf242('0x28')](_0xf242('0x91'),_0xf242('0x8b'),_0xf242('0x8d'),util[_0xf242('0x92')](_0x3c678a[_0xf242('0x58')],{'showHidden':![],'depth':null}));}break;}return _0x3d5fa5;}})[_0xf242('0x22')](respondWithResult(_0x16308e,null))['catch'](handleError(_0x16308e,null));};
\ No newline at end of file
+var _0xf025=['../../config/environment','../../mysqldb','redis','defaults','socket.io-emitter','./whatsappMessage.socket','register','client','http','request','then','info','WhatsappMessage,\x20%s,\x20%s','request\x20sent','WhatsappMessage,\x20%s,\x20%s,\x20%s','stringify','error','message','catch','sendStatus','status','json','offset','undefined','count','limit','set','Content-Range','update','end','stack','name','send','map','WhatsappMessage','rawAttributes','fieldName','model','query','keys','intersection','attributes','fields','hasOwnProperty','nolimit','order','sort','pick','filter','where','type','VIRTUAL','merge','options','includeAll','include','findAll','rows','show','length','find','create','params','body','describe','whatsapp-interactions','accept','whatsapp','read','readAt','YYYY-MM-DD\x20HH:mm:ss','UserId','user','agent','WhatsappInteraction','WhatsappInteractionId','isNil','read1stAt','format','interaction','get','[WHATSAPPMESSAGE:ACCEPT]\x20id=%s\x20name=%s\x20role=%s\x20interaction=%s\x20body=%s','role','null','AcceptMessage','SELECT\x20*\x20FROM\x20cm_contacts\x20WHERE\x20id\x20=\x20','ContactId','sequelize','Sequelize','QueryTypes','SELECT','contact','User','fullname','email','internal','manual','channel','motionChannel','event','EventManager','acceptmessage','reject','[WHATSAPPMESSAGE:REJECT]\x20id=%s\x20name=%s\x20role=%s\x20interaction=%s\x20body=%s','RejectMessage','rejectMessage','SIP/%s','WhatsappAccount','WhatsappAccountId','debug','received\x20delivery\x20report\x20from','inspect','MessageSid','messageId','MessageStatus','WhatsappAccount,\x20%s,\x20%s,\x20%s','twilio','eml-format','fast-json-patch','request-promise','moment','util','path','to-csv','lodash','squel','crypto','jsforce','papaparse','ioredis','../../components/parsers/qs','../../config/logger','../../config/utils'];(function(_0x589002,_0x1c9c42){var _0x1ebe5a=function(_0x7f9547){while(--_0x7f9547){_0x589002['push'](_0x589002['shift']());}};_0x1ebe5a(++_0x1c9c42);}(_0xf025,0x17f));var _0x5f02=function(_0x4fbb15,_0x21be0c){_0x4fbb15=_0x4fbb15-0x0;var _0x436338=_0xf025[_0x4fbb15];return _0x436338;};'use strict';var emlformat=require(_0x5f02('0x0'));var rimraf=require('rimraf');var zipdir=require('zip-dir');var jsonpatch=require(_0x5f02('0x1'));var rp=require(_0x5f02('0x2'));var moment=require(_0x5f02('0x3'));var BPromise=require('bluebird');var Mustache=require('mustache');var util=require(_0x5f02('0x4'));var path=require(_0x5f02('0x5'));var sox=require('sox');var csv=require(_0x5f02('0x6'));var ejs=require('ejs');var fs=require('fs');var fs_extra=require('fs-extra');var _=require(_0x5f02('0x7'));var squel=require(_0x5f02('0x8'));var crypto=require(_0x5f02('0x9'));var jsforce=require(_0x5f02('0xa'));var deskjs=require('desk.js');var toCsv=require(_0x5f02('0x6'));var querystring=require('querystring');var Papa=require(_0x5f02('0xb'));var Redis=require(_0x5f02('0xc'));var authService=require('../../components/auth/service');var qs=require(_0x5f02('0xd'));var as=require('../../components/parsers/advancedSearch');var hardwareService=require('../../config/license/hardware');var logger=require(_0x5f02('0xe'))('api');var utils=require(_0x5f02('0xf'));var config=require(_0x5f02('0x10'));var licenseUtil=require('../../config/license/util');var db=require(_0x5f02('0x11'))['db'];config[_0x5f02('0x12')]=_[_0x5f02('0x13')](config[_0x5f02('0x12')],{'host':'localhost','port':0x18eb});var socket=require(_0x5f02('0x14'))(new Redis(config[_0x5f02('0x12')]));require(_0x5f02('0x15'))[_0x5f02('0x16')](socket);var jayson=require('jayson/promise');var client=jayson[_0x5f02('0x17')][_0x5f02('0x18')]({'port':0x232c});var client9002=jayson[_0x5f02('0x17')]['http']({'port':0x232a});function respondWithRpcPromise(_0x31bcb0,_0x12cea2,_0x2fcecc,_0x4391f6){return new BPromise(function(_0x249b10,_0x2e5f6b){var _0x4c87f1=_0x4391f6||client;return _0x4c87f1[_0x5f02('0x19')](_0x31bcb0,_0x2fcecc)[_0x5f02('0x1a')](function(_0xe4c8a5){logger[_0x5f02('0x1b')](_0x5f02('0x1c'),_0x12cea2,_0x5f02('0x1d'));logger['debug'](_0x5f02('0x1e'),_0x12cea2,'request\x20sent',JSON[_0x5f02('0x1f')](_0xe4c8a5));if(_0xe4c8a5[_0x5f02('0x20')]){if(_0xe4c8a5['error']['code']===0x1f4){logger[_0x5f02('0x20')](_0x5f02('0x1c'),_0x12cea2,_0xe4c8a5[_0x5f02('0x20')][_0x5f02('0x21')]);return _0x2e5f6b(_0xe4c8a5[_0x5f02('0x20')]['message']);}logger[_0x5f02('0x20')](_0x5f02('0x1c'),_0x12cea2,_0xe4c8a5[_0x5f02('0x20')][_0x5f02('0x21')]);return _0x249b10(_0xe4c8a5['error'][_0x5f02('0x21')]);}else{logger['info']('WhatsappMessage,\x20%s,\x20%s',_0x12cea2,_0x5f02('0x1d'));_0x249b10(_0xe4c8a5['result'][_0x5f02('0x21')]);}})[_0x5f02('0x22')](function(_0x4b7ed5){logger['error'](_0x5f02('0x1c'),_0x12cea2,_0x4b7ed5);_0x2e5f6b(_0x4b7ed5);});});}function respondWithStatusCode(_0x46d1f0,_0x225d04){_0x225d04=_0x225d04||0xcc;return function(_0x1fec38){if(_0x1fec38){return _0x46d1f0[_0x5f02('0x23')](_0x225d04);}return _0x46d1f0[_0x5f02('0x24')](_0x225d04)['end']();};}function respondWithResult(_0x447651,_0x3544c3){_0x3544c3=_0x3544c3||0xc8;return function(_0x20b841){if(_0x20b841){return _0x447651[_0x5f02('0x24')](_0x3544c3)[_0x5f02('0x25')](_0x20b841);}};}function respondWithFilteredResult(_0x187e4e,_0x537503){return function(_0x416789){if(_0x416789){var _0x37f5ed=typeof _0x537503[_0x5f02('0x26')]==='undefined'&&typeof _0x537503['limit']===_0x5f02('0x27');var _0x374c1e=_0x416789[_0x5f02('0x28')];var _0x11a250=_0x37f5ed?0x0:_0x537503[_0x5f02('0x26')];var _0x2a792a=_0x37f5ed?_0x416789[_0x5f02('0x28')]:_0x537503[_0x5f02('0x26')]+_0x537503[_0x5f02('0x29')];var _0x4e3b20;if(_0x2a792a>=_0x374c1e){_0x2a792a=_0x374c1e;_0x4e3b20=0xc8;}else{_0x4e3b20=0xce;}_0x187e4e[_0x5f02('0x24')](_0x4e3b20);return _0x187e4e[_0x5f02('0x2a')](_0x5f02('0x2b'),_0x11a250+'-'+_0x2a792a+'/'+_0x374c1e)[_0x5f02('0x25')](_0x416789);}return null;};}function patchUpdates(_0x557671){return function(_0x2753e9){try{jsonpatch['apply'](_0x2753e9,_0x557671,!![]);}catch(_0x40d13e){return BPromise['reject'](_0x40d13e);}return _0x2753e9['save']();};}function saveUpdates(_0x3a392e,_0x1b2492){return function(_0x5adb09){if(_0x5adb09){return _0x5adb09[_0x5f02('0x2c')](_0x3a392e)[_0x5f02('0x1a')](function(_0x37023e){return _0x37023e;});}return null;};}function removeEntity(_0x3ccef7,_0x2142e2){return function(_0x55fecb){if(_0x55fecb){return _0x55fecb['destroy']()[_0x5f02('0x1a')](function(){_0x3ccef7[_0x5f02('0x24')](0xcc)[_0x5f02('0x2d')]();});}};}function handleEntityNotFound(_0x36fea6,_0x370c28){return function(_0x27418c){if(!_0x27418c){_0x36fea6[_0x5f02('0x23')](0x194);}return _0x27418c;};}function handleError(_0x7145e3,_0xf8be88){_0xf8be88=_0xf8be88||0x1f4;return function(_0x5811d7){logger[_0x5f02('0x20')](_0x5811d7[_0x5f02('0x2e')]);if(_0x5811d7[_0x5f02('0x2f')]){delete _0x5811d7[_0x5f02('0x2f')];}_0x7145e3[_0x5f02('0x24')](_0xf8be88)[_0x5f02('0x30')](_0x5811d7);};}exports['index']=function(_0x2f31a2,_0x4e33ef){var _0x489072={},_0x489774={},_0xe97ac2={'count':0x0,'rows':[]};var _0x1dcebf=_[_0x5f02('0x31')](db[_0x5f02('0x32')][_0x5f02('0x33')],function(_0x2fcd02){return{'name':_0x2fcd02[_0x5f02('0x34')],'type':_0x2fcd02['type']['key']};});_0x489774[_0x5f02('0x35')]=_['map'](_0x1dcebf,_0x5f02('0x2f'));_0x489774[_0x5f02('0x36')]=_[_0x5f02('0x37')](_0x2f31a2[_0x5f02('0x36')]);_0x489774['filters']=_[_0x5f02('0x38')](_0x489774[_0x5f02('0x35')],_0x489774['query']);_0x489072[_0x5f02('0x39')]=_[_0x5f02('0x38')](_0x489774[_0x5f02('0x35')],qs[_0x5f02('0x3a')](_0x2f31a2['query'][_0x5f02('0x3a')]));_0x489072[_0x5f02('0x39')]=_0x489072[_0x5f02('0x39')]['length']?_0x489072[_0x5f02('0x39')]:_0x489774[_0x5f02('0x35')];if(!_0x2f31a2['query'][_0x5f02('0x3b')](_0x5f02('0x3c'))){_0x489072[_0x5f02('0x29')]=qs[_0x5f02('0x29')](_0x2f31a2['query'][_0x5f02('0x29')]);_0x489072['offset']=qs[_0x5f02('0x26')](_0x2f31a2[_0x5f02('0x36')]['offset']);}_0x489072[_0x5f02('0x3d')]=qs[_0x5f02('0x3e')](_0x2f31a2[_0x5f02('0x36')][_0x5f02('0x3e')]);_0x489072['where']=qs['filters'](_[_0x5f02('0x3f')](_0x2f31a2['query'],_0x489774['filters']),_0x1dcebf);if(_0x2f31a2['query'][_0x5f02('0x40')]){_0x489072[_0x5f02('0x41')]=_['merge'](_0x489072[_0x5f02('0x41')],{'$or':_[_0x5f02('0x31')](_0x1dcebf,function(_0x1e2560){if(_0x1e2560[_0x5f02('0x42')]!==_0x5f02('0x43')){var _0x1d1815={};_0x1d1815[_0x1e2560[_0x5f02('0x2f')]]={'$like':'%'+_0x2f31a2['query'][_0x5f02('0x40')]+'%'};return _0x1d1815;}})});}_0x489072=_[_0x5f02('0x44')]({},_0x489072,_0x2f31a2[_0x5f02('0x45')]);var _0x158528={'where':_0x489072[_0x5f02('0x41')]};return db[_0x5f02('0x32')][_0x5f02('0x28')](_0x158528)['then'](function(_0x15cd74){_0xe97ac2['count']=_0x15cd74;if(_0x2f31a2[_0x5f02('0x36')][_0x5f02('0x46')]){_0x489072[_0x5f02('0x47')]=[{'all':!![]}];}return db[_0x5f02('0x32')][_0x5f02('0x48')](_0x489072);})[_0x5f02('0x1a')](function(_0x2482c8){_0xe97ac2[_0x5f02('0x49')]=_0x2482c8;return _0xe97ac2;})[_0x5f02('0x1a')](respondWithFilteredResult(_0x4e33ef,_0x489072))[_0x5f02('0x22')](handleError(_0x4e33ef,null));};exports[_0x5f02('0x4a')]=function(_0x2aca96,_0x53c2cf){var _0x5efaf9={'raw':!![],'where':{'id':_0x2aca96['params']['id']}},_0x3e6b3f={};_0x3e6b3f[_0x5f02('0x35')]=_[_0x5f02('0x37')](db[_0x5f02('0x32')][_0x5f02('0x33')]);_0x3e6b3f[_0x5f02('0x36')]=_[_0x5f02('0x37')](_0x2aca96[_0x5f02('0x36')]);_0x3e6b3f['filters']=_[_0x5f02('0x38')](_0x3e6b3f[_0x5f02('0x35')],_0x3e6b3f[_0x5f02('0x36')]);_0x5efaf9['attributes']=_[_0x5f02('0x38')](_0x3e6b3f[_0x5f02('0x35')],qs['fields'](_0x2aca96['query'][_0x5f02('0x3a')]));_0x5efaf9[_0x5f02('0x39')]=_0x5efaf9[_0x5f02('0x39')][_0x5f02('0x4b')]?_0x5efaf9['attributes']:_0x3e6b3f[_0x5f02('0x35')];if(_0x2aca96[_0x5f02('0x36')][_0x5f02('0x46')]){_0x5efaf9[_0x5f02('0x47')]=[{'all':!![]}];}_0x5efaf9=_[_0x5f02('0x44')]({},_0x5efaf9,_0x2aca96[_0x5f02('0x45')]);return db[_0x5f02('0x32')][_0x5f02('0x4c')](_0x5efaf9)[_0x5f02('0x1a')](handleEntityNotFound(_0x53c2cf,null))[_0x5f02('0x1a')](respondWithResult(_0x53c2cf,null))[_0x5f02('0x22')](handleError(_0x53c2cf,null));};exports[_0x5f02('0x4d')]=function(_0x3f8f4b,_0x57be5c){return db[_0x5f02('0x32')]['create'](_0x3f8f4b['body'],{})[_0x5f02('0x1a')](respondWithResult(_0x57be5c,0xc9))[_0x5f02('0x22')](handleError(_0x57be5c,null));};exports['update']=function(_0x20009f,_0x31bc70){if(_0x20009f['body']['id']){delete _0x20009f['body']['id'];}return db[_0x5f02('0x32')][_0x5f02('0x4c')]({'where':{'id':_0x20009f[_0x5f02('0x4e')]['id']}})[_0x5f02('0x1a')](handleEntityNotFound(_0x31bc70,null))[_0x5f02('0x1a')](saveUpdates(_0x20009f[_0x5f02('0x4f')],null))[_0x5f02('0x1a')](respondWithResult(_0x31bc70,null))[_0x5f02('0x22')](handleError(_0x31bc70,null));};exports['destroy']=function(_0x5d0416,_0x3d55c2){return db['WhatsappMessage']['find']({'where':{'id':_0x5d0416[_0x5f02('0x4e')]['id']}})[_0x5f02('0x1a')](handleEntityNotFound(_0x3d55c2,null))[_0x5f02('0x1a')](removeEntity(_0x3d55c2,null))[_0x5f02('0x22')](handleError(_0x3d55c2,null));};exports['describe']=function(_0x5970e4,_0x2433b8){return db[_0x5f02('0x32')][_0x5f02('0x50')]()[_0x5f02('0x1a')](respondWithResult(_0x2433b8,null))[_0x5f02('0x22')](handleError(_0x2433b8,null));};var interaction_log=require(_0x5f02('0xe'))(_0x5f02('0x51'));exports[_0x5f02('0x52')]=function(_0x129bcf,_0x3166f,_0x3f1280){var _0x228f2c={'agent':{},'channel':_0x5f02('0x53')};if(_0x129bcf[_0x5f02('0x4f')]['id']){delete _0x129bcf[_0x5f02('0x4f')]['id'];}_0x129bcf['body'][_0x5f02('0x54')]=!![];_0x129bcf[_0x5f02('0x4f')][_0x5f02('0x55')]=moment()['format'](_0x5f02('0x56'));_0x129bcf[_0x5f02('0x4f')][_0x5f02('0x57')]=_0x129bcf['body'][_0x5f02('0x57')]||_0x129bcf[_0x5f02('0x58')]['id'];_0x228f2c[_0x5f02('0x59')]['id']=_0x129bcf[_0x5f02('0x4f')][_0x5f02('0x57')];return db[_0x5f02('0x32')][_0x5f02('0x4c')]({'where':{'id':_0x129bcf[_0x5f02('0x4e')]['id'],'UserId':null}})['then'](handleEntityNotFound(_0x3166f,null))['then'](saveUpdates(_0x129bcf[_0x5f02('0x4f')],null))['then'](function(_0x5e16d0){if(_0x5e16d0){_0x228f2c[_0x5f02('0x21')]=_0x5e16d0['get']({'plain':!![]});return db[_0x5f02('0x5a')]['find']({'where':{'id':_0x5e16d0[_0x5f02('0x5b')]}});}return null;})[_0x5f02('0x1a')](handleEntityNotFound(_0x3166f,null))[_0x5f02('0x1a')](function(_0x917287){if(_0x917287){return _0x917287['update']({'UserId':_0x129bcf[_0x5f02('0x4f')][_0x5f02('0x57')],'read1stAt':_[_0x5f02('0x5c')](_0x917287[_0x5f02('0x5d')])?moment()[_0x5f02('0x5e')]('YYYY-MM-DD\x20HH:mm:ss'):undefined});}return null;})['then'](function(_0x44aab9){if(_0x44aab9){_0x228f2c[_0x5f02('0x5f')]=_0x44aab9[_0x5f02('0x60')]({'plain':!![]});interaction_log[_0x5f02('0x1b')](_0x5f02('0x61'),_0x129bcf[_0x5f02('0x58')]['id'],_0x129bcf['user']['name'],_0x129bcf[_0x5f02('0x58')][_0x5f02('0x62')],_0x228f2c[_0x5f02('0x5f')]['id'],_0x129bcf[_0x5f02('0x4f')]?JSON[_0x5f02('0x1f')](_0x129bcf['body']):_0x5f02('0x63'));return respondWithRpcPromise(_0x5f02('0x64'),'acceptMessage',_0x228f2c);}return null;})[_0x5f02('0x1a')](function(_0x49d449){var _0x5c0591=_0x5f02('0x65')+_0x49d449['message'][_0x5f02('0x66')];return db[_0x5f02('0x67')][_0x5f02('0x36')](_0x5c0591,{'type':db[_0x5f02('0x68')][_0x5f02('0x69')][_0x5f02('0x6a')],'raw':!![]})[_0x5f02('0x1a')](function(_0x214f90){return _0x214f90;});})[_0x5f02('0x1a')](function(_0x2e5fd6){if(_0x2e5fd6){_0x228f2c[_0x5f02('0x21')][_0x5f02('0x6b')]=_0x2e5fd6[0x0];if(!_0x129bcf[_0x5f02('0x4f')][_0x5f02('0x57')])return;return db[_0x5f02('0x6c')][_0x5f02('0x4c')]({'where':{'id':_0x129bcf[_0x5f02('0x4f')][_0x5f02('0x57')],'role':_0x5f02('0x59')},'attributes':['id',_0x5f02('0x2f'),_0x5f02('0x6d'),_0x5f02('0x6e'),_0x5f02('0x6f')],'raw':!![]});}return null;})['then'](function(_0x3b911c){if(!_0x3b911c)return null;_0x228f2c[_0x5f02('0x21')][_0x5f02('0x59')]=_0x3b911c;return _0x228f2c;})[_0x5f02('0x1a')](function(_0x46ee41){if(_0x46ee41){if(_0x129bcf[_0x5f02('0x4f')][_0x5f02('0x70')]){_0x228f2c['message']['interface']=util['format']('SIP/%s',_0x129bcf['user'][_0x5f02('0x2f')]);_0x228f2c['message'][_0x5f02('0x71')]=_0x228f2c[_0x5f02('0x71')];_0x228f2c['message'][_0x5f02('0x72')]=_0x228f2c['channel'];_0x228f2c['message'][_0x5f02('0x73')]=_0x5f02('0x52');return respondWithRpcPromise(_0x5f02('0x74'),_0x5f02('0x74'),{'event':_0x5f02('0x75'),'message':_0x228f2c[_0x5f02('0x21')]},client9002)['then'](function(){return _0x228f2c;});}return _0x228f2c;}return null;})[_0x5f02('0x1a')](respondWithResult(_0x3166f,null))[_0x5f02('0x22')](handleError(_0x3166f,null));};var interaction_log=require(_0x5f02('0xe'))(_0x5f02('0x51'));exports[_0x5f02('0x76')]=function(_0x155ac8,_0x14da0b,_0x3c3a54){var _0x4dc5aa={'agent':{},'channel':_0x5f02('0x53')};if(_0x155ac8[_0x5f02('0x4f')]['id']){delete _0x155ac8['body']['id'];}_0x155ac8[_0x5f02('0x4f')][_0x5f02('0x57')]=_0x155ac8['body'][_0x5f02('0x57')]||_0x155ac8[_0x5f02('0x58')]['id'];_0x4dc5aa['agent']['id']=_0x155ac8['body']['UserId'];return db['WhatsappMessage'][_0x5f02('0x4c')]({'where':{'id':_0x155ac8[_0x5f02('0x4e')]['id'],'UserId':null}})[_0x5f02('0x1a')](handleEntityNotFound(_0x14da0b,null))[_0x5f02('0x1a')](function(_0x25d4f7){if(_0x25d4f7){_0x4dc5aa[_0x5f02('0x21')]=_0x25d4f7[_0x5f02('0x60')]({'plain':!![]});return db[_0x5f02('0x5a')]['find']({'where':{'id':_0x25d4f7[_0x5f02('0x5b')]}});}return null;})['then'](handleEntityNotFound(_0x14da0b,null))['then'](function(_0x18755c){if(_0x18755c){_0x4dc5aa[_0x5f02('0x5f')]=_0x18755c['get']({'plain':!![]});interaction_log[_0x5f02('0x1b')](_0x5f02('0x77'),_0x155ac8['user']['id'],_0x155ac8[_0x5f02('0x58')][_0x5f02('0x2f')],_0x155ac8[_0x5f02('0x58')][_0x5f02('0x62')],_0x4dc5aa['interaction']['id'],_0x155ac8['body']?JSON[_0x5f02('0x1f')](_0x155ac8[_0x5f02('0x4f')]):_0x5f02('0x63'));return respondWithRpcPromise(_0x5f02('0x78'),_0x5f02('0x79'),_0x4dc5aa);}return null;})[_0x5f02('0x1a')](function(_0x24b95c){var _0x225627='SELECT\x20*\x20FROM\x20cm_contacts\x20WHERE\x20id\x20=\x20'+_0x24b95c['message'][_0x5f02('0x66')];return db['sequelize'][_0x5f02('0x36')](_0x225627,{'type':db[_0x5f02('0x68')]['QueryTypes'][_0x5f02('0x6a')],'raw':!![]})[_0x5f02('0x1a')](function(_0xf1af2f){return _0xf1af2f;});})[_0x5f02('0x1a')](function(_0x47d9eb){if(_0x47d9eb){_0x4dc5aa['message']['contact']=_0x47d9eb[0x0];if(!_0x155ac8[_0x5f02('0x4f')]['UserId'])return;return db[_0x5f02('0x6c')][_0x5f02('0x4c')]({'where':{'id':_0x155ac8[_0x5f02('0x4f')]['UserId'],'role':_0x5f02('0x59')},'attributes':['id','name','fullname',_0x5f02('0x6e'),_0x5f02('0x6f')],'raw':!![]});}return null;})[_0x5f02('0x1a')](function(_0x71e80c){if(!_0x71e80c)return null;_0x4dc5aa[_0x5f02('0x21')]['agent']=_0x71e80c;return _0x4dc5aa;})[_0x5f02('0x1a')](function(_0x3fce64){if(_0x3fce64){_0x3fce64[_0x5f02('0x21')]['interface']=util['format'](_0x5f02('0x7a'),_0x155ac8[_0x5f02('0x58')][_0x5f02('0x2f')]);_0x3fce64[_0x5f02('0x21')][_0x5f02('0x71')]=_0x4dc5aa[_0x5f02('0x71')];_0x3fce64[_0x5f02('0x21')][_0x5f02('0x72')]=_0x4dc5aa[_0x5f02('0x71')];_0x3fce64[_0x5f02('0x21')][_0x5f02('0x73')]=_0x5f02('0x76');respondWithRpcPromise('EventManager','EventManager',{'event':'rejectmessage','message':_0x3fce64[_0x5f02('0x21')]},client9002);return _0x4dc5aa;}return null;})['then'](respondWithResult(_0x14da0b,null))['catch'](handleError(_0x14da0b,null));};exports[_0x5f02('0x24')]=function(_0x51daa9,_0x2ec1f7,_0x3ccbee){if(_0x51daa9['body']['id']){delete _0x51daa9['body']['id'];}var _0x9ee2a4;return db[_0x5f02('0x32')][_0x5f02('0x4c')]({'where':{'id':_0x51daa9[_0x5f02('0x4e')]['id']}})[_0x5f02('0x1a')](handleEntityNotFound(_0x2ec1f7,null))[_0x5f02('0x1a')](function(_0x3162dc){if(_0x3162dc){_0x9ee2a4=_0x3162dc;return db[_0x5f02('0x7b')][_0x5f02('0x4c')]({'where':{'id':_0x3162dc[_0x5f02('0x7c')]}});}})[_0x5f02('0x1a')](handleEntityNotFound(_0x2ec1f7,null))['then'](function(_0x2a2473){if(_0x2a2473){logger[_0x5f02('0x7d')]('WhatsppMessage,\x20%s,\x20%s,\x20%s',_0x5f02('0x24'),_0x5f02('0x7e'),_0x2a2473[_0x5f02('0x42')],util[_0x5f02('0x7f')](_0x51daa9[_0x5f02('0x4f')],{'showHidden':![],'depth':null}));switch(_0x2a2473['type']){case'twilio':if(_0x51daa9[_0x5f02('0x4f')][_0x5f02('0x80')]&&_0x51daa9[_0x5f02('0x4f')][_0x5f02('0x80')]===_0x9ee2a4[_0x5f02('0x81')]&&_0x51daa9[_0x5f02('0x4f')]['MessageStatus']&&_0x51daa9['body'][_0x5f02('0x82')]==='read'){return _0x9ee2a4[_0x5f02('0x2c')]({'read':!![]});}else{logger['error'](_0x5f02('0x83'),'status',_0x5f02('0x84'),util[_0x5f02('0x7f')](_0x51daa9[_0x5f02('0x4f')],{'showHidden':![],'depth':null}));}break;}return _0x9ee2a4;}})['then'](respondWithResult(_0x2ec1f7,null))[_0x5f02('0x22')](handleError(_0x2ec1f7,null));};
\ No newline at end of file