Built motion from commit (unavailable).|2.5.26
[motion2.git] / server / api / cmHopper / cmHopper.controller.js
index c182950..ee8bf77 100644 (file)
@@ -15,4 +15,4 @@
 // * treaties. The SOFTWARE PRODUCT is licensed, not sold.                        *
 // *                                                                       *
 // *************************************************************************
-var _0x6cff=['then','count','includeAll','include','findAll','rows','catch','params','keys','CmHopper','rawAttributes','options','find','body','describe','VoiceQueueId','CampaignId','VoiceQueue','Campaign','omit','dataValues','createdAt','updatedAt','state','statedesc','deleted','membername','user','UserId','deletedat','format','calleridnum','phone','campaigntype','queue','ivr','CmContact','lastName','isNil','firstName','finally','CmHopperFinal','create','CRIS\x20DELETEHOPPER----','CmHopperAdditionalPhone','getPreview','getVoiceQueues','outbound','preview','dialOrderByScheduledAt','sequelize','YYYY-MM-DD\x20HH:mm:ss','direction','prev','isEmpty','hopperIds','DESC','ASC','literal','COALESCE(CmHopper.UserId,\x200)\x20ASC','priority','COALESCE(CmHopper.UserId,\x200)\x20DESC','scheduledat','LOCK','UPDATE','Contact','CmCompany','CmList','List','Queue','getOpenContacts','isNumber','CmHopper,\x20%s,\x20%s,\x20%s','entity\x20not\x20found','html-pdf','eml-format','rimraf','fast-json-patch','moment','bluebird','path','sox','to-csv','fs-extra','squel','jsforce','querystring','ioredis','../../components/auth/service','../../components/parsers/qs','../../config/license/hardware','../../config/logger','api','../../config/utils','../../config/environment','../../config/license/util','../../mysqldb','status','json','offset','limit','Content-Range','apply','reject','update','destroy','end','sendStatus','error','stack','name','index','map','fieldName','type','model','query','filters','concat','$or','$gte','$not','$between','$notBetween','$in','$notIn','$notLike','$notILike','$contains','$any','attributes','intersection','fields','length','hasOwnProperty','nolimit','order','sort','pick','filter','where','merge'];(function(_0x45d3f0,_0x4be53f){var _0x314b79=function(_0x563d32){while(--_0x563d32){_0x45d3f0['push'](_0x45d3f0['shift']());}};_0x314b79(++_0x4be53f);}(_0x6cff,0x166));var _0xf6cf=function(_0x20229e,_0xa59f8a){_0x20229e=_0x20229e-0x0;var _0x317377=_0x6cff[_0x20229e];return _0x317377;};'use strict';var pdf=require(_0xf6cf('0x0'));var emlformat=require(_0xf6cf('0x1'));var rimraf=require(_0xf6cf('0x2'));var zipdir=require('zip-dir');var jsonpatch=require(_0xf6cf('0x3'));var rp=require('request-promise');var moment=require(_0xf6cf('0x4'));var BPromise=require(_0xf6cf('0x5'));var Mustache=require('mustache');var util=require('util');var path=require(_0xf6cf('0x6'));var sox=require(_0xf6cf('0x7'));var csv=require(_0xf6cf('0x8'));var ejs=require('ejs');var fs=require('fs');var fs_extra=require(_0xf6cf('0x9'));var _=require('lodash');var squel=require(_0xf6cf('0xa'));var crypto=require('crypto');var jsforce=require(_0xf6cf('0xb'));var deskjs=require('desk.js');var toCsv=require(_0xf6cf('0x8'));var querystring=require(_0xf6cf('0xc'));var Papa=require('papaparse');var Redis=require(_0xf6cf('0xd'));var authService=require(_0xf6cf('0xe'));var qs=require(_0xf6cf('0xf'));var as=require('../../components/parsers/advancedSearch');var hardwareService=require(_0xf6cf('0x10'));var logger=require(_0xf6cf('0x11'))(_0xf6cf('0x12'));var utils=require(_0xf6cf('0x13'));var config=require(_0xf6cf('0x14'));var licenseUtil=require(_0xf6cf('0x15'));var db=require(_0xf6cf('0x16'))['db'];function respondWithStatusCode(_0x229b77,_0x55d423){_0x55d423=_0x55d423||0xcc;return function(_0x136e83){if(_0x136e83){return _0x229b77['sendStatus'](_0x55d423);}return _0x229b77[_0xf6cf('0x17')](_0x55d423)['end']();};}function respondWithResult(_0x180ebe,_0x238639){_0x238639=_0x238639||0xc8;return function(_0x4034e4){if(_0x4034e4){return _0x180ebe[_0xf6cf('0x17')](_0x238639)[_0xf6cf('0x18')](_0x4034e4);}};}function respondWithFilteredResult(_0x477bb6,_0x4fb943){return function(_0x4b6550){if(_0x4b6550){var _0xed1e04=_0x4b6550['count'],_0x290b7e=_0x4fb943[_0xf6cf('0x19')],_0x375298=_0x4fb943['offset']+_0x4fb943[_0xf6cf('0x1a')],_0x5cba2f;if(_0x375298>=_0xed1e04){_0x375298=_0xed1e04;_0x5cba2f=0xc8;}else{_0x5cba2f=0xce;}_0x477bb6[_0xf6cf('0x17')](_0x5cba2f);return _0x477bb6['set'](_0xf6cf('0x1b'),_0x290b7e+'-'+_0x375298+'/'+_0xed1e04)[_0xf6cf('0x18')](_0x4b6550);}return null;};}function patchUpdates(_0x2793af){return function(_0x4ea023){try{jsonpatch[_0xf6cf('0x1c')](_0x4ea023,_0x2793af,!![]);}catch(_0x3150f0){return BPromise[_0xf6cf('0x1d')](_0x3150f0);}return _0x4ea023['save']();};}function saveUpdates(_0x41b098,_0x2a2f5c){return function(_0x5886e6){if(_0x5886e6){return _0x5886e6[_0xf6cf('0x1e')](_0x41b098)['then'](function(_0x2ce5b1){return _0x2ce5b1;});}return null;};}function removeEntity(_0x31765f,_0x82eb05){return function(_0xd185d0){if(_0xd185d0){return _0xd185d0[_0xf6cf('0x1f')]()['then'](function(){_0x31765f[_0xf6cf('0x17')](0xcc)[_0xf6cf('0x20')]();});}};}function handleEntityNotFound(_0x164e57,_0x1266c8){return function(_0x285621){if(!_0x285621){_0x164e57[_0xf6cf('0x21')](0x194);}return _0x285621;};}function handleError(_0x52d88d,_0x203414){_0x203414=_0x203414||0x1f4;return function(_0x506422){logger[_0xf6cf('0x22')](_0x506422[_0xf6cf('0x23')]);if(_0x506422[_0xf6cf('0x24')]){delete _0x506422[_0xf6cf('0x24')];}_0x52d88d[_0xf6cf('0x17')](_0x203414)['send'](_0x506422);};}exports[_0xf6cf('0x25')]=function(_0xbc2e24,_0x1404bf){var _0x461acc={},_0x1ef30f={},_0x3b9124={'count':0x0,'rows':[]};var _0x27f0d4=_[_0xf6cf('0x26')](db['CmHopper']['rawAttributes'],function(_0x3420ea){return{'name':_0x3420ea[_0xf6cf('0x27')],'type':_0x3420ea[_0xf6cf('0x28')]['key']};});_0x1ef30f[_0xf6cf('0x29')]=_['map'](_0x27f0d4,'name');_0x1ef30f[_0xf6cf('0x2a')]=_['keys'](_0xbc2e24[_0xf6cf('0x2a')]);_0x1ef30f[_0xf6cf('0x2b')]=_['intersection'](_0x1ef30f[_0xf6cf('0x29')],_0x1ef30f[_0xf6cf('0x2a')]);_0x1ef30f[_0xf6cf('0x2b')]=_[_0xf6cf('0x2c')](_0x1ef30f['filters'],['$and',_0xf6cf('0x2d'),'$gt',_0xf6cf('0x2e'),'$lt','$lte','$ne','$eq',_0xf6cf('0x2f'),_0xf6cf('0x30'),_0xf6cf('0x31'),_0xf6cf('0x32'),_0xf6cf('0x33'),'$like',_0xf6cf('0x34'),'$iLike',_0xf6cf('0x35'),'$like','$overlap',_0xf6cf('0x36'),'$contained',_0xf6cf('0x37')]);_0x461acc[_0xf6cf('0x38')]=_[_0xf6cf('0x39')](_0x1ef30f[_0xf6cf('0x29')],qs[_0xf6cf('0x3a')](_0xbc2e24['query'][_0xf6cf('0x3a')]));_0x461acc[_0xf6cf('0x38')]=_0x461acc[_0xf6cf('0x38')][_0xf6cf('0x3b')]?_0x461acc[_0xf6cf('0x38')]:_0x1ef30f[_0xf6cf('0x29')];if(!_0xbc2e24[_0xf6cf('0x2a')][_0xf6cf('0x3c')](_0xf6cf('0x3d'))){_0x461acc[_0xf6cf('0x1a')]=qs[_0xf6cf('0x1a')](_0xbc2e24[_0xf6cf('0x2a')]['limit']);_0x461acc[_0xf6cf('0x19')]=qs[_0xf6cf('0x19')](_0xbc2e24['query'][_0xf6cf('0x19')]);}_0x461acc[_0xf6cf('0x3e')]=qs['sort'](_0xbc2e24['query'][_0xf6cf('0x3f')]);_0x461acc['where']=qs[_0xf6cf('0x2b')](_[_0xf6cf('0x40')](_0xbc2e24[_0xf6cf('0x2a')],_0x1ef30f['filters']),_0x27f0d4);if(_0xbc2e24[_0xf6cf('0x2a')][_0xf6cf('0x41')]){_0x461acc[_0xf6cf('0x42')]=_[_0xf6cf('0x43')](_0x461acc['where'],{'$or':_[_0xf6cf('0x26')](_0x27f0d4,function(_0x35c821){if(_0x35c821[_0xf6cf('0x28')]!=='VIRTUAL'){var _0x2e1de8={};_0x2e1de8[_0x35c821['name']]={'$like':'%'+_0xbc2e24['query']['filter']+'%'};return _0x2e1de8;}})});}_0x461acc=_[_0xf6cf('0x43')]({},_0x461acc,_0xbc2e24['options']);var _0x13d22c={'where':_0x461acc[_0xf6cf('0x42')]};return db['CmHopper']['count'](_0x13d22c)[_0xf6cf('0x44')](function(_0x29fd2e){_0x3b9124[_0xf6cf('0x45')]=_0x29fd2e;if(_0xbc2e24[_0xf6cf('0x2a')][_0xf6cf('0x46')]){_0x461acc[_0xf6cf('0x47')]=[{'all':!![]}];}return db['CmHopper'][_0xf6cf('0x48')](_0x461acc);})[_0xf6cf('0x44')](function(_0x23f5aa){_0x3b9124[_0xf6cf('0x49')]=_0x23f5aa;return _0x3b9124;})[_0xf6cf('0x44')](respondWithFilteredResult(_0x1404bf,_0x461acc))[_0xf6cf('0x4a')](handleError(_0x1404bf,null));};exports['show']=function(_0x309fe7,_0x28e672){var _0x2adaba={'raw':!![],'where':{'id':_0x309fe7[_0xf6cf('0x4b')]['id']}},_0x30d896={};_0x30d896['model']=_[_0xf6cf('0x4c')](db[_0xf6cf('0x4d')][_0xf6cf('0x4e')]);_0x30d896[_0xf6cf('0x2a')]=_[_0xf6cf('0x4c')](_0x309fe7[_0xf6cf('0x2a')]);_0x30d896[_0xf6cf('0x2b')]=_[_0xf6cf('0x39')](_0x30d896[_0xf6cf('0x29')],_0x30d896[_0xf6cf('0x2a')]);_0x2adaba[_0xf6cf('0x38')]=_[_0xf6cf('0x39')](_0x30d896[_0xf6cf('0x29')],qs[_0xf6cf('0x3a')](_0x309fe7[_0xf6cf('0x2a')][_0xf6cf('0x3a')]));_0x2adaba[_0xf6cf('0x38')]=_0x2adaba[_0xf6cf('0x38')]['length']?_0x2adaba[_0xf6cf('0x38')]:_0x30d896[_0xf6cf('0x29')];if(_0x309fe7['query'][_0xf6cf('0x46')]){_0x2adaba[_0xf6cf('0x47')]=[{'all':!![]}];}_0x2adaba=_[_0xf6cf('0x43')]({},_0x2adaba,_0x309fe7[_0xf6cf('0x4f')]);return db[_0xf6cf('0x4d')][_0xf6cf('0x50')](_0x2adaba)[_0xf6cf('0x44')](handleEntityNotFound(_0x28e672,null))['then'](respondWithResult(_0x28e672,null))[_0xf6cf('0x4a')](handleError(_0x28e672,null));};exports['create']=function(_0x41f001,_0x388375){return db[_0xf6cf('0x4d')]['create'](_0x41f001[_0xf6cf('0x51')],{})[_0xf6cf('0x44')](respondWithResult(_0x388375,0xc9))[_0xf6cf('0x4a')](handleError(_0x388375,null));};exports['update']=function(_0x4911ef,_0x3e5bd2){if(_0x4911ef[_0xf6cf('0x51')]['id']){delete _0x4911ef[_0xf6cf('0x51')]['id'];}return db[_0xf6cf('0x4d')][_0xf6cf('0x50')]({'where':{'id':_0x4911ef[_0xf6cf('0x4b')]['id']}})['then'](handleEntityNotFound(_0x3e5bd2,null))[_0xf6cf('0x44')](saveUpdates(_0x4911ef[_0xf6cf('0x51')],null))['then'](respondWithResult(_0x3e5bd2,null))[_0xf6cf('0x4a')](handleError(_0x3e5bd2,null));};exports[_0xf6cf('0x52')]=function(_0x5e9807,_0x178f50){return db[_0xf6cf('0x4d')][_0xf6cf('0x52')]()[_0xf6cf('0x44')](respondWithResult(_0x178f50,null))[_0xf6cf('0x4a')](handleError(_0x178f50,null));};exports['destroy']=function(_0x20ab73,_0x165f94){var _0xaa954a;var _0x4d5df8=_0x20ab73[_0xf6cf('0x4b')]['id'];return db[_0xf6cf('0x4d')][_0xf6cf('0x50')]({'where':{'id':_0x20ab73[_0xf6cf('0x4b')]['id']}})[_0xf6cf('0x44')](handleEntityNotFound(_0x165f94,null))[_0xf6cf('0x44')](function(_0xc0aa69){if(_0xc0aa69){return _0xc0aa69[_0xf6cf('0x1f')]()[_0xf6cf('0x44')](function(_0x324e03){return _0x324e03;});}})['then'](function(_0x408db5){_0xaa954a=_0x408db5;if(_0x408db5){if(_0x408db5[_0xf6cf('0x53')]||_0x408db5[_0xf6cf('0x54')]){return db[_0x408db5[_0xf6cf('0x53')]?_0xf6cf('0x55'):_0xf6cf('0x56')][_0xf6cf('0x50')]({'where':{'id':_0x408db5['VoiceQueueId']?_0x408db5[_0xf6cf('0x53')]:_0x408db5[_0xf6cf('0x54')]},'attributes':['id',_0xf6cf('0x24')],'raw':!![]});}}})[_0xf6cf('0x44')](function(_0x2c238a){var _0x3124de={};if(_0x2c238a){_[_0xf6cf('0x43')](_0x3124de,_[_0xf6cf('0x57')](_0xaa954a[_0xf6cf('0x58')],[_0xf6cf('0x59'),_0xf6cf('0x5a'),'id']));_0x3124de[_0xf6cf('0x5b')]=0x15;_0x3124de[_0xf6cf('0x5c')]=_0xf6cf('0x5d');_0x3124de['campaign']=_0x2c238a[_0xf6cf('0x24')];_0x3124de[_0xf6cf('0x5e')]=_0x20ab73[_0xf6cf('0x5f')][_0xf6cf('0x24')];_0x3124de[_0xf6cf('0x60')]=_0x20ab73[_0xf6cf('0x5f')]['id'];_0x3124de['deleted']=!![];_0x3124de[_0xf6cf('0x61')]=moment()[_0xf6cf('0x62')]('YYYY-MM-DD\x20HH:mm:ss');_0x3124de[_0xf6cf('0x63')]=_0xaa954a[_0xf6cf('0x64')];_0x3124de[_0xf6cf('0x65')]=_0xaa954a[_0xf6cf('0x53')]?_0xf6cf('0x66'):_0xf6cf('0x67');return db[_0xf6cf('0x68')]['find']({'where':{'id':_0x3124de['ContactId']},'attributes':['firstName',_0xf6cf('0x69')]})[_0xf6cf('0x44')](function(_0x1229d6){if(!_[_0xf6cf('0x6a')](_0x165f94)&&!_['isNil'](_0x1229d6[_0xf6cf('0x6b')])){_0x3124de['calleridname']=_0x1229d6['firstName'];if(!_[_0xf6cf('0x6a')](_0x1229d6[_0xf6cf('0x69')])){_0x3124de['calleridname']+='\x20'+_0x1229d6['lastName'];}}})[_0xf6cf('0x6c')](function(){return db[_0xf6cf('0x6d')][_0xf6cf('0x6e')](_0x3124de);});}})['then'](function(_0x3ee731){console['log'](_0xf6cf('0x6f')+_0x4d5df8);return db[_0xf6cf('0x70')][_0xf6cf('0x1f')]({'where':{'CmHopperId':_0x4d5df8}});})[_0xf6cf('0x44')](function(){return _0x165f94[_0xf6cf('0x17')](0xcc)['end']();})[_0xf6cf('0x4a')](handleError(_0x165f94,null));};exports[_0xf6cf('0x71')]=function(_0x2d2377,_0x277a0c,_0x59e1cf){var _0x2325fd=[];return db[_0xf6cf('0x68')]['describe']()[_0xf6cf('0x44')](function(_0x2eede1){_0x2325fd=_['keys'](_0x2eede1);return _0x2d2377[_0xf6cf('0x5f')][_0xf6cf('0x72')]({'where':{'type':_0xf6cf('0x73'),'dialActive':!![],'dialMethod':_0xf6cf('0x74')},'attributes':['id',_0xf6cf('0x75')],'raw':!![]});})[_0xf6cf('0x44')](function(_0x4910de){if(_0x4910de&&_0x4910de[_0xf6cf('0x3b')]){return db[_0xf6cf('0x76')]['transaction'](function(_0x522d28){var _0x4b2202={'active':![],'recallme':![],'scheduledAt':{'$lte':moment()[_0xf6cf('0x62')](_0xf6cf('0x77'))},'VoiceQueueId':{'$in':_[_0xf6cf('0x26')](_0x4910de,'id')},'$or':[{'UserId':null},{'UserId':_0x2d2377[_0xf6cf('0x5f')]['id']}]};var _0x4d9b97=[];if(_0x2d2377[_0xf6cf('0x51')][_0xf6cf('0x78')]&&_0x2d2377['body']['direction']===_0xf6cf('0x79')){if(!_[_0xf6cf('0x7a')](_0x2d2377[_0xf6cf('0x51')][_0xf6cf('0x7b')])){_0x4b2202['id']={'$in':_0x2d2377[_0xf6cf('0x51')][_0xf6cf('0x7b')]};}_0x4d9b97=[['priority','ASC'],['scheduledAt',_0x4910de[0x0]['dialOrderByScheduledAt']==='ASC'?_0xf6cf('0x7c'):_0xf6cf('0x7d')],db[_0xf6cf('0x76')][_0xf6cf('0x7e')](_0xf6cf('0x7f')),['id','DESC']];}else{if(!_[_0xf6cf('0x7a')](_0x2d2377[_0xf6cf('0x51')][_0xf6cf('0x7b')])){_0x4b2202['id']={'$notIn':_0x2d2377[_0xf6cf('0x51')]['hopperIds']};}_0x4d9b97=[[_0xf6cf('0x80'),_0xf6cf('0x7c')],['scheduledAt',_0x4910de[0x0]['dialOrderByScheduledAt']],db[_0xf6cf('0x76')][_0xf6cf('0x7e')](_0xf6cf('0x81')),['id','ASC']];}return db['CmHopper']['findOne']({'attributes':['id',_0xf6cf('0x82'),_0xf6cf('0x64')],'where':_0x4b2202,'order':_0x4d9b97,'transaction':_0x522d28,'lock':_0x522d28[_0xf6cf('0x83')][_0xf6cf('0x84')],'include':[{'model':db['CmContact'],'as':_0xf6cf('0x85'),'attributes':_0x2325fd,'include':[{'model':db[_0xf6cf('0x86')],'as':'Company','attributes':['id',_0xf6cf('0x24')]}]},{'model':db[_0xf6cf('0x87')],'as':_0xf6cf('0x88'),'attributes':['id',_0xf6cf('0x24')]},{'model':db['VoiceQueue'],'as':_0xf6cf('0x89'),'attributes':['id',_0xf6cf('0x24'),'dialActive']}]})['then'](function(_0x40252d){if(_0x40252d){return _0x40252d[_0xf6cf('0x1e')]({'UserId':_0x2d2377[_0xf6cf('0x5f')]['id']},{'transaction':_0x522d28});}});});}})[_0xf6cf('0x44')](handleEntityNotFound(_0x277a0c,null))['then'](respondWithResult(_0x277a0c,null))[_0xf6cf('0x4a')](handleError(_0x277a0c,null));};exports[_0xf6cf('0x8a')]=function(_0x2630c2,_0x26fcc1,_0x5975b1){return _0x2630c2[_0xf6cf('0x5f')]['getVoiceQueues']({'where':{'type':_0xf6cf('0x73'),'dialActive':!![],'dialMethod':_0xf6cf('0x74')},'attributes':['id'],'raw':!![]})[_0xf6cf('0x44')](function(_0x204d86){if(_0x204d86&&_0x204d86[_0xf6cf('0x3b')]){return db[_0xf6cf('0x4d')][_0xf6cf('0x45')]({'where':{'active':![],'recallme':![],'scheduledAt':{'$lte':moment()[_0xf6cf('0x62')](_0xf6cf('0x77'))},'VoiceQueueId':{'$in':_[_0xf6cf('0x26')](_0x204d86,'id')},'$or':[{'UserId':null},{'UserId':_0x2630c2[_0xf6cf('0x5f')]['id']}]}});}return 0x0;})[_0xf6cf('0x44')](function(_0x295be4){if(!_[_0xf6cf('0x6a')](_0x295be4)&&_[_0xf6cf('0x8b')](_0x295be4)){return _0x26fcc1[_0xf6cf('0x17')](0xc8)[_0xf6cf('0x18')]({'contacts':_0x295be4});}else{logger[_0xf6cf('0x22')](_0xf6cf('0x8c'),_0xf6cf('0x8a'),0x194,_0xf6cf('0x8d'));_0x26fcc1[_0xf6cf('0x21')](0x194);}})[_0xf6cf('0x4a')](handleError(_0x26fcc1,null));};
\ No newline at end of file
+var _0x4f82=['calleridnum','phone','campaigntype','queue','ivr','ContactId','firstName','lastName','isNil','calleridname','finally','CmHopperAdditionalPhone','getPreview','CmContact','getVoiceQueues','outbound','preview','direction','prev','hopperIds','priority','ASC','scheduledAt','dialOrderByScheduledAt','COALESCE(CmHopper.UserId,\x200)\x20ASC','DESC','isEmpty','sequelize','COALESCE(CmHopper.UserId,\x200)\x20DESC','scheduledat','LOCK','Company','CmList','List','Queue','dialActive','getOpenContacts','isNumber','CmHopper,\x20%s,\x20%s,\x20%s','entity\x20not\x20found','html-pdf','eml-format','zip-dir','request-promise','bluebird','util','path','sox','to-csv','fs-extra','lodash','squel','crypto','jsforce','desk.js','querystring','papaparse','ioredis','../../components/auth/service','../../components/parsers/advancedSearch','../../config/utils','../../config/license/util','sendStatus','status','end','json','count','offset','limit','set','Content-Range','apply','reject','then','destroy','error','stack','name','send','index','map','CmHopper','fieldName','type','key','query','intersection','model','filters','concat','$and','$or','$gte','$lt','$lte','$ne','$eq','$not','$notBetween','$in','$notIn','$like','$notLike','$notILike','$overlap','$contains','$contained','$any','attributes','fields','length','nolimit','order','sort','pick','filter','where','merge','VIRTUAL','options','includeAll','findAll','rows','catch','show','params','keys','rawAttributes','find','create','body','update','describe','VoiceQueueId','CampaignId','VoiceQueue','Campaign','dataValues','createdAt','updatedAt','statedesc','deleted','campaign','user','UserId','deletedat','format','YYYY-MM-DD\x20HH:mm:ss'];(function(_0xad500b,_0x58a97d){var _0x42f2f2=function(_0x5371b8){while(--_0x5371b8){_0xad500b['push'](_0xad500b['shift']());}};_0x42f2f2(++_0x58a97d);}(_0x4f82,0xbc));var _0x24f8=function(_0x15c421,_0x6366f7){_0x15c421=_0x15c421-0x0;var _0x5e5ed5=_0x4f82[_0x15c421];return _0x5e5ed5;};'use strict';var pdf=require(_0x24f8('0x0'));var emlformat=require(_0x24f8('0x1'));var rimraf=require('rimraf');var zipdir=require(_0x24f8('0x2'));var jsonpatch=require('fast-json-patch');var rp=require(_0x24f8('0x3'));var moment=require('moment');var BPromise=require(_0x24f8('0x4'));var Mustache=require('mustache');var util=require(_0x24f8('0x5'));var path=require(_0x24f8('0x6'));var sox=require(_0x24f8('0x7'));var csv=require(_0x24f8('0x8'));var ejs=require('ejs');var fs=require('fs');var fs_extra=require(_0x24f8('0x9'));var _=require(_0x24f8('0xa'));var squel=require(_0x24f8('0xb'));var crypto=require(_0x24f8('0xc'));var jsforce=require(_0x24f8('0xd'));var deskjs=require(_0x24f8('0xe'));var toCsv=require('to-csv');var querystring=require(_0x24f8('0xf'));var Papa=require(_0x24f8('0x10'));var Redis=require(_0x24f8('0x11'));var authService=require(_0x24f8('0x12'));var qs=require('../../components/parsers/qs');var as=require(_0x24f8('0x13'));var hardwareService=require('../../config/license/hardware');var logger=require('../../config/logger')('api');var utils=require(_0x24f8('0x14'));var config=require('../../config/environment');var licenseUtil=require(_0x24f8('0x15'));var db=require('../../mysqldb')['db'];function respondWithStatusCode(_0x516ea1,_0x1f73ec){_0x1f73ec=_0x1f73ec||0xcc;return function(_0x31c123){if(_0x31c123){return _0x516ea1[_0x24f8('0x16')](_0x1f73ec);}return _0x516ea1[_0x24f8('0x17')](_0x1f73ec)[_0x24f8('0x18')]();};}function respondWithResult(_0x10fa27,_0x3d0d87){_0x3d0d87=_0x3d0d87||0xc8;return function(_0x2e312d){if(_0x2e312d){return _0x10fa27[_0x24f8('0x17')](_0x3d0d87)[_0x24f8('0x19')](_0x2e312d);}};}function respondWithFilteredResult(_0x319c54,_0x57d554){return function(_0x3a4760){if(_0x3a4760){var _0x2a980d=_0x3a4760[_0x24f8('0x1a')],_0x191bc9=_0x57d554[_0x24f8('0x1b')],_0x3552aa=_0x57d554[_0x24f8('0x1b')]+_0x57d554[_0x24f8('0x1c')],_0x1083a8;if(_0x3552aa>=_0x2a980d){_0x3552aa=_0x2a980d;_0x1083a8=0xc8;}else{_0x1083a8=0xce;}_0x319c54[_0x24f8('0x17')](_0x1083a8);return _0x319c54[_0x24f8('0x1d')](_0x24f8('0x1e'),_0x191bc9+'-'+_0x3552aa+'/'+_0x2a980d)['json'](_0x3a4760);}return null;};}function patchUpdates(_0x3ac69c){return function(_0x35eb3){try{jsonpatch[_0x24f8('0x1f')](_0x35eb3,_0x3ac69c,!![]);}catch(_0x59f1d5){return BPromise[_0x24f8('0x20')](_0x59f1d5);}return _0x35eb3['save']();};}function saveUpdates(_0x5c0232,_0x11548c){return function(_0x163d41){if(_0x163d41){return _0x163d41['update'](_0x5c0232)[_0x24f8('0x21')](function(_0x5ac5e){return _0x5ac5e;});}return null;};}function removeEntity(_0x873e4e,_0x4f2f5d){return function(_0x510505){if(_0x510505){return _0x510505[_0x24f8('0x22')]()[_0x24f8('0x21')](function(){_0x873e4e[_0x24f8('0x17')](0xcc)[_0x24f8('0x18')]();});}};}function handleEntityNotFound(_0x40790b,_0x3fcf7b){return function(_0x5cd49a){if(!_0x5cd49a){_0x40790b[_0x24f8('0x16')](0x194);}return _0x5cd49a;};}function handleError(_0x58a288,_0x200d47){_0x200d47=_0x200d47||0x1f4;return function(_0x3b89b5){logger[_0x24f8('0x23')](_0x3b89b5[_0x24f8('0x24')]);if(_0x3b89b5[_0x24f8('0x25')]){delete _0x3b89b5[_0x24f8('0x25')];}_0x58a288[_0x24f8('0x17')](_0x200d47)[_0x24f8('0x26')](_0x3b89b5);};}exports[_0x24f8('0x27')]=function(_0x206ca9,_0x533ce9){var _0xd8ef1f={},_0x2290ff={},_0x47370b={'count':0x0,'rows':[]};var _0x2d3aa3=_[_0x24f8('0x28')](db[_0x24f8('0x29')]['rawAttributes'],function(_0x26e3cf){return{'name':_0x26e3cf[_0x24f8('0x2a')],'type':_0x26e3cf[_0x24f8('0x2b')][_0x24f8('0x2c')]};});_0x2290ff['model']=_[_0x24f8('0x28')](_0x2d3aa3,_0x24f8('0x25'));_0x2290ff[_0x24f8('0x2d')]=_['keys'](_0x206ca9['query']);_0x2290ff['filters']=_[_0x24f8('0x2e')](_0x2290ff[_0x24f8('0x2f')],_0x2290ff[_0x24f8('0x2d')]);_0x2290ff[_0x24f8('0x30')]=_[_0x24f8('0x31')](_0x2290ff[_0x24f8('0x30')],[_0x24f8('0x32'),_0x24f8('0x33'),'$gt',_0x24f8('0x34'),_0x24f8('0x35'),_0x24f8('0x36'),_0x24f8('0x37'),_0x24f8('0x38'),_0x24f8('0x39'),'$between',_0x24f8('0x3a'),_0x24f8('0x3b'),_0x24f8('0x3c'),_0x24f8('0x3d'),_0x24f8('0x3e'),'$iLike',_0x24f8('0x3f'),_0x24f8('0x3d'),_0x24f8('0x40'),_0x24f8('0x41'),_0x24f8('0x42'),_0x24f8('0x43')]);_0xd8ef1f[_0x24f8('0x44')]=_[_0x24f8('0x2e')](_0x2290ff['model'],qs[_0x24f8('0x45')](_0x206ca9[_0x24f8('0x2d')][_0x24f8('0x45')]));_0xd8ef1f[_0x24f8('0x44')]=_0xd8ef1f[_0x24f8('0x44')][_0x24f8('0x46')]?_0xd8ef1f['attributes']:_0x2290ff['model'];if(!_0x206ca9[_0x24f8('0x2d')]['hasOwnProperty'](_0x24f8('0x47'))){_0xd8ef1f['limit']=qs['limit'](_0x206ca9['query'][_0x24f8('0x1c')]);_0xd8ef1f[_0x24f8('0x1b')]=qs[_0x24f8('0x1b')](_0x206ca9['query']['offset']);}_0xd8ef1f[_0x24f8('0x48')]=qs[_0x24f8('0x49')](_0x206ca9[_0x24f8('0x2d')][_0x24f8('0x49')]);_0xd8ef1f['where']=qs[_0x24f8('0x30')](_[_0x24f8('0x4a')](_0x206ca9[_0x24f8('0x2d')],_0x2290ff['filters']),_0x2d3aa3);if(_0x206ca9[_0x24f8('0x2d')][_0x24f8('0x4b')]){_0xd8ef1f[_0x24f8('0x4c')]=_[_0x24f8('0x4d')](_0xd8ef1f[_0x24f8('0x4c')],{'$or':_[_0x24f8('0x28')](_0x2d3aa3,function(_0x13ce93){if(_0x13ce93['type']!==_0x24f8('0x4e')){var _0x2c9ae9={};_0x2c9ae9[_0x13ce93['name']]={'$like':'%'+_0x206ca9[_0x24f8('0x2d')][_0x24f8('0x4b')]+'%'};return _0x2c9ae9;}})});}_0xd8ef1f=_[_0x24f8('0x4d')]({},_0xd8ef1f,_0x206ca9[_0x24f8('0x4f')]);var _0x33102a={'where':_0xd8ef1f[_0x24f8('0x4c')]};return db[_0x24f8('0x29')][_0x24f8('0x1a')](_0x33102a)[_0x24f8('0x21')](function(_0x489617){_0x47370b['count']=_0x489617;if(_0x206ca9['query'][_0x24f8('0x50')]){_0xd8ef1f['include']=[{'all':!![]}];}return db['CmHopper'][_0x24f8('0x51')](_0xd8ef1f);})[_0x24f8('0x21')](function(_0x2b73df){_0x47370b[_0x24f8('0x52')]=_0x2b73df;return _0x47370b;})[_0x24f8('0x21')](respondWithFilteredResult(_0x533ce9,_0xd8ef1f))[_0x24f8('0x53')](handleError(_0x533ce9,null));};exports[_0x24f8('0x54')]=function(_0x31a9e4,_0x5e60fa){var _0x3f3929={'raw':!![],'where':{'id':_0x31a9e4[_0x24f8('0x55')]['id']}},_0x2fd59f={};_0x2fd59f[_0x24f8('0x2f')]=_[_0x24f8('0x56')](db[_0x24f8('0x29')][_0x24f8('0x57')]);_0x2fd59f['query']=_[_0x24f8('0x56')](_0x31a9e4[_0x24f8('0x2d')]);_0x2fd59f[_0x24f8('0x30')]=_['intersection'](_0x2fd59f[_0x24f8('0x2f')],_0x2fd59f[_0x24f8('0x2d')]);_0x3f3929[_0x24f8('0x44')]=_['intersection'](_0x2fd59f[_0x24f8('0x2f')],qs[_0x24f8('0x45')](_0x31a9e4[_0x24f8('0x2d')][_0x24f8('0x45')]));_0x3f3929[_0x24f8('0x44')]=_0x3f3929[_0x24f8('0x44')][_0x24f8('0x46')]?_0x3f3929[_0x24f8('0x44')]:_0x2fd59f[_0x24f8('0x2f')];if(_0x31a9e4[_0x24f8('0x2d')]['includeAll']){_0x3f3929['include']=[{'all':!![]}];}_0x3f3929=_[_0x24f8('0x4d')]({},_0x3f3929,_0x31a9e4[_0x24f8('0x4f')]);return db[_0x24f8('0x29')][_0x24f8('0x58')](_0x3f3929)[_0x24f8('0x21')](handleEntityNotFound(_0x5e60fa,null))['then'](respondWithResult(_0x5e60fa,null))[_0x24f8('0x53')](handleError(_0x5e60fa,null));};exports[_0x24f8('0x59')]=function(_0x248c4b,_0x132258){return db[_0x24f8('0x29')][_0x24f8('0x59')](_0x248c4b[_0x24f8('0x5a')],{})['then'](respondWithResult(_0x132258,0xc9))[_0x24f8('0x53')](handleError(_0x132258,null));};exports[_0x24f8('0x5b')]=function(_0x139120,_0x2ce0ae){if(_0x139120[_0x24f8('0x5a')]['id']){delete _0x139120['body']['id'];}return db[_0x24f8('0x29')][_0x24f8('0x58')]({'where':{'id':_0x139120[_0x24f8('0x55')]['id']}})[_0x24f8('0x21')](handleEntityNotFound(_0x2ce0ae,null))[_0x24f8('0x21')](saveUpdates(_0x139120[_0x24f8('0x5a')],null))[_0x24f8('0x21')](respondWithResult(_0x2ce0ae,null))[_0x24f8('0x53')](handleError(_0x2ce0ae,null));};exports[_0x24f8('0x5c')]=function(_0x50a165,_0x47de09){return db['CmHopper'][_0x24f8('0x5c')]()[_0x24f8('0x21')](respondWithResult(_0x47de09,null))[_0x24f8('0x53')](handleError(_0x47de09,null));};exports[_0x24f8('0x22')]=function(_0x49b230,_0x65853f){var _0x15df7b;var _0x4a6efb=_0x49b230[_0x24f8('0x55')]['id'];return db['CmHopper'][_0x24f8('0x58')]({'where':{'id':_0x49b230['params']['id']}})[_0x24f8('0x21')](handleEntityNotFound(_0x65853f,null))[_0x24f8('0x21')](function(_0x4d85ca){if(_0x4d85ca){return _0x4d85ca['destroy']()['then'](function(_0x5bb998){return _0x5bb998;});}})['then'](function(_0x4292bb){_0x15df7b=_0x4292bb;if(_0x4292bb){if(_0x4292bb[_0x24f8('0x5d')]||_0x4292bb[_0x24f8('0x5e')]){return db[_0x4292bb[_0x24f8('0x5d')]?_0x24f8('0x5f'):_0x24f8('0x60')][_0x24f8('0x58')]({'where':{'id':_0x4292bb[_0x24f8('0x5d')]?_0x4292bb[_0x24f8('0x5d')]:_0x4292bb[_0x24f8('0x5e')]},'attributes':['id',_0x24f8('0x25')],'raw':!![]});}}})['then'](function(_0x4d2a44){var _0x47aa5c={};if(_0x4d2a44){_['merge'](_0x47aa5c,_['omit'](_0x15df7b[_0x24f8('0x61')],[_0x24f8('0x62'),_0x24f8('0x63'),'id']));_0x47aa5c['state']=0x15;_0x47aa5c[_0x24f8('0x64')]=_0x24f8('0x65');_0x47aa5c[_0x24f8('0x66')]=_0x4d2a44['name'];_0x47aa5c['membername']=_0x49b230[_0x24f8('0x67')][_0x24f8('0x25')];_0x47aa5c[_0x24f8('0x68')]=_0x49b230[_0x24f8('0x67')]['id'];_0x47aa5c['deleted']=!![];_0x47aa5c[_0x24f8('0x69')]=moment()[_0x24f8('0x6a')](_0x24f8('0x6b'));_0x47aa5c[_0x24f8('0x6c')]=_0x15df7b[_0x24f8('0x6d')];_0x47aa5c[_0x24f8('0x6e')]=_0x15df7b[_0x24f8('0x5d')]?_0x24f8('0x6f'):_0x24f8('0x70');return db['CmContact'][_0x24f8('0x58')]({'where':{'id':_0x47aa5c[_0x24f8('0x71')]},'attributes':[_0x24f8('0x72'),_0x24f8('0x73')]})[_0x24f8('0x21')](function(_0x105c7e){if(!_[_0x24f8('0x74')](_0x65853f)&&!_[_0x24f8('0x74')](_0x105c7e[_0x24f8('0x72')])){_0x47aa5c[_0x24f8('0x75')]=_0x105c7e[_0x24f8('0x72')];if(!_[_0x24f8('0x74')](_0x105c7e[_0x24f8('0x73')])){_0x47aa5c['calleridname']+='\x20'+_0x105c7e[_0x24f8('0x73')];}}})[_0x24f8('0x76')](function(){return db['CmHopperFinal']['create'](_0x47aa5c);});}})[_0x24f8('0x21')](function(_0x596e5a){return db[_0x24f8('0x77')][_0x24f8('0x22')]({'where':{'CmHopperId':_0x4a6efb}});})[_0x24f8('0x21')](function(){return _0x65853f[_0x24f8('0x17')](0xcc)['end']();})[_0x24f8('0x53')](handleError(_0x65853f,null));};exports[_0x24f8('0x78')]=function(_0xfe23dd,_0x5eeb65,_0x59c903){var _0x3b4339=[];return db[_0x24f8('0x79')][_0x24f8('0x5c')]()[_0x24f8('0x21')](function(_0x4f9059){_0x3b4339=_['keys'](_0x4f9059);return _0xfe23dd[_0x24f8('0x67')][_0x24f8('0x7a')]({'where':{'type':_0x24f8('0x7b'),'dialActive':!![],'dialMethod':_0x24f8('0x7c')},'attributes':['id','dialOrderByScheduledAt'],'raw':!![]});})['then'](function(_0x5755b7){if(_0x5755b7&&_0x5755b7[_0x24f8('0x46')]){return db['sequelize']['transaction'](function(_0x29206d){var _0x88ca2f={'active':![],'recallme':![],'scheduledAt':{'$lte':moment()['format'](_0x24f8('0x6b'))},'VoiceQueueId':{'$in':_[_0x24f8('0x28')](_0x5755b7,'id')},'$or':[{'UserId':null},{'UserId':_0xfe23dd[_0x24f8('0x67')]['id']}]};var _0x214392=[];if(_0xfe23dd[_0x24f8('0x5a')][_0x24f8('0x7d')]&&_0xfe23dd['body'][_0x24f8('0x7d')]===_0x24f8('0x7e')){if(!_['isEmpty'](_0xfe23dd[_0x24f8('0x5a')][_0x24f8('0x7f')])){_0x88ca2f['id']={'$in':_0xfe23dd[_0x24f8('0x5a')][_0x24f8('0x7f')]};}_0x214392=[[_0x24f8('0x80'),_0x24f8('0x81')],[_0x24f8('0x82'),_0x5755b7[0x0][_0x24f8('0x83')]===_0x24f8('0x81')?'DESC':'ASC'],db['sequelize']['literal'](_0x24f8('0x84')),['id',_0x24f8('0x85')]];}else{if(!_[_0x24f8('0x86')](_0xfe23dd[_0x24f8('0x5a')][_0x24f8('0x7f')])){_0x88ca2f['id']={'$notIn':_0xfe23dd[_0x24f8('0x5a')][_0x24f8('0x7f')]};}_0x214392=[['priority',_0x24f8('0x85')],[_0x24f8('0x82'),_0x5755b7[0x0][_0x24f8('0x83')]],db[_0x24f8('0x87')]['literal'](_0x24f8('0x88')),['id',_0x24f8('0x81')]];}return db[_0x24f8('0x29')]['findOne']({'attributes':['id',_0x24f8('0x89'),_0x24f8('0x6d')],'where':_0x88ca2f,'order':_0x214392,'transaction':_0x29206d,'lock':_0x29206d[_0x24f8('0x8a')]['UPDATE'],'include':[{'model':db[_0x24f8('0x79')],'as':'Contact','attributes':_0x3b4339,'include':[{'model':db['CmCompany'],'as':_0x24f8('0x8b'),'attributes':['id',_0x24f8('0x25')]}]},{'model':db[_0x24f8('0x8c')],'as':_0x24f8('0x8d'),'attributes':['id','name']},{'model':db['VoiceQueue'],'as':_0x24f8('0x8e'),'attributes':['id',_0x24f8('0x25'),_0x24f8('0x8f')]}]})[_0x24f8('0x21')](function(_0x23a8ca){if(_0x23a8ca){return _0x23a8ca['update']({'UserId':_0xfe23dd[_0x24f8('0x67')]['id']},{'transaction':_0x29206d});}});});}})[_0x24f8('0x21')](handleEntityNotFound(_0x5eeb65,null))[_0x24f8('0x21')](respondWithResult(_0x5eeb65,null))[_0x24f8('0x53')](handleError(_0x5eeb65,null));};exports[_0x24f8('0x90')]=function(_0x4a6c79,_0x164995,_0x371c25){return _0x4a6c79[_0x24f8('0x67')][_0x24f8('0x7a')]({'where':{'type':_0x24f8('0x7b'),'dialActive':!![],'dialMethod':_0x24f8('0x7c')},'attributes':['id'],'raw':!![]})[_0x24f8('0x21')](function(_0x2e58e3){if(_0x2e58e3&&_0x2e58e3[_0x24f8('0x46')]){return db['CmHopper']['count']({'where':{'active':![],'recallme':![],'scheduledAt':{'$lte':moment()[_0x24f8('0x6a')](_0x24f8('0x6b'))},'VoiceQueueId':{'$in':_[_0x24f8('0x28')](_0x2e58e3,'id')},'$or':[{'UserId':null},{'UserId':_0x4a6c79['user']['id']}]}});}return 0x0;})['then'](function(_0x101d39){if(!_[_0x24f8('0x74')](_0x101d39)&&_[_0x24f8('0x91')](_0x101d39)){return _0x164995[_0x24f8('0x17')](0xc8)['json']({'contacts':_0x101d39});}else{logger[_0x24f8('0x23')](_0x24f8('0x92'),_0x24f8('0x90'),0x194,_0x24f8('0x93'));_0x164995[_0x24f8('0x16')](0x194);}})[_0x24f8('0x53')](handleError(_0x164995,null));};
\ No newline at end of file