Built motion from commit d1eab355.|2.6.28
[motion2.git] / server / api / cmHopper / cmHopper.controller.js
index b95f9c5..f1735fb 100644 (file)
@@ -15,4 +15,4 @@
 // * treaties. The SOFTWARE PRODUCT is licensed, not sold.                        *
 // *                                                                       *
 // *************************************************************************
-var _0xe5b3=['value','direction','prev','hopperIds','ASC','scheduledAt','DESC','literal','COALESCE(CmHopper.UserId,\x200)\x20ASC','isEmpty','dialOrderByScheduledAt','COALESCE(CmHopper.UserId,\x200)\x20DESC','scheduledat','LOCK','UPDATE','CmContact','Contact','CmCompany','Company','List','dialActive','getPreviewRecall','findOne','Queue','getOpenContacts','preview','CmHopper,\x20%s,\x20%s,\x20%s','entity\x20not\x20found','getTimezones','push','utcOffset','getTimezone','timezones','lodash','../../components/parsers/qs','../../config/logger','api','../../config/environment','../../mysqldb','status','json','offset','undefined','limit','count','set','Content-Range','update','sendStatus','error','name','index','map','CmHopper','rawAttributes','fieldName','type','key','model','query','keys','filters','concat','$and','$gt','$gte','$lte','$ne','$eq','$not','$between','$notBetween','$in','$notIn','$notLike','$notILike','$overlap','$contains','$contained','$any','attributes','intersection','fields','length','hasOwnProperty','nolimit','order','sort','where','pick','filter','VIRTUAL','merge','includeAll','include','findAll','params','options','find','then','catch','create','body','describe','destroy','VoiceQueueId','CampaignId','VoiceQueue','Campaign','omit','dataValues','createdAt','updatedAt','statedesc','user','UserId','calleridnum','phone','campaigntype','queue','ContactId','firstName','lastName','calleridname','isNil','finally','CmHopperFinal','CmHopperAdditionalPhone','end','getPreview','getVoiceQueues','outbound','dialPreviewAutoRecallMe','sequelize','transaction','format','YYYY-MM-DD\x20HH:mm:ss'];(function(_0x26f075,_0x35cdbe){var _0x50b848=function(_0x52f7c2){while(--_0x52f7c2){_0x26f075['push'](_0x26f075['shift']());}};_0x50b848(++_0x35cdbe);}(_0xe5b3,0x133));var _0x3e5b=function(_0x253ed4,_0x342aca){_0x253ed4=_0x253ed4-0x0;var _0x22df23=_0xe5b3[_0x253ed4];return _0x22df23;};'use strict';var moment=require('moment');var _=require(_0x3e5b('0x0'));var qs=require(_0x3e5b('0x1'));var logger=require(_0x3e5b('0x2'))(_0x3e5b('0x3'));var shared=require(_0x3e5b('0x4'));var db=require(_0x3e5b('0x5'))['db'];function respondWithResult(_0x7f1cc0,_0x1e58ed){_0x1e58ed=_0x1e58ed||0xc8;return function(_0x320b1e){if(_0x320b1e){return _0x7f1cc0[_0x3e5b('0x6')](_0x1e58ed)[_0x3e5b('0x7')](_0x320b1e);}};}function respondWithFilteredResult(_0x54e1fb,_0x174923){return function(_0x5dcf55){if(_0x5dcf55){var _0x534e7d=typeof _0x174923[_0x3e5b('0x8')]===_0x3e5b('0x9')&&typeof _0x174923[_0x3e5b('0xa')]===_0x3e5b('0x9');var _0x5282fd=_0x5dcf55['count'];var _0x1fef54=_0x534e7d?0x0:_0x174923[_0x3e5b('0x8')];var _0x22fc1a=_0x534e7d?_0x5dcf55[_0x3e5b('0xb')]:_0x174923[_0x3e5b('0x8')]+_0x174923['limit'];var _0x3be027;if(_0x22fc1a>=_0x5282fd){_0x22fc1a=_0x5282fd;_0x3be027=0xc8;}else{_0x3be027=0xce;}_0x54e1fb['status'](_0x3be027);return _0x54e1fb[_0x3e5b('0xc')](_0x3e5b('0xd'),_0x1fef54+'-'+_0x22fc1a+'/'+_0x5282fd)[_0x3e5b('0x7')](_0x5dcf55);}return null;};}function saveUpdates(_0x374068,_0x20b97b){return function(_0x3c4eb1){if(_0x3c4eb1){return _0x3c4eb1[_0x3e5b('0xe')](_0x374068)['then'](function(_0x39a2a1){return _0x39a2a1;});}return null;};}function handleEntityNotFound(_0x5f2f9c,_0x51a188){return function(_0x4d71a3){if(!_0x4d71a3){_0x5f2f9c[_0x3e5b('0xf')](0x194);}return _0x4d71a3;};}function handleError(_0x3f5368,_0x17aaa3){_0x17aaa3=_0x17aaa3||0x1f4;return function(_0x4fb471){logger[_0x3e5b('0x10')](_0x4fb471['stack']);if(_0x4fb471['name']){delete _0x4fb471[_0x3e5b('0x11')];}_0x3f5368[_0x3e5b('0x6')](_0x17aaa3)['send'](_0x4fb471);};}exports[_0x3e5b('0x12')]=function(_0x143040,_0x555002){var _0xc56a2a={},_0x3365dd={},_0x52696c={'count':0x0,'rows':[]};var _0x4b189d=_[_0x3e5b('0x13')](db[_0x3e5b('0x14')][_0x3e5b('0x15')],function(_0xff4aba){return{'name':_0xff4aba[_0x3e5b('0x16')],'type':_0xff4aba[_0x3e5b('0x17')][_0x3e5b('0x18')]};});_0x3365dd[_0x3e5b('0x19')]=_[_0x3e5b('0x13')](_0x4b189d,_0x3e5b('0x11'));_0x3365dd[_0x3e5b('0x1a')]=_[_0x3e5b('0x1b')](_0x143040[_0x3e5b('0x1a')]);_0x3365dd[_0x3e5b('0x1c')]=_['intersection'](_0x3365dd[_0x3e5b('0x19')],_0x3365dd[_0x3e5b('0x1a')]);_0x3365dd[_0x3e5b('0x1c')]=_[_0x3e5b('0x1d')](_0x3365dd['filters'],[_0x3e5b('0x1e'),'$or',_0x3e5b('0x1f'),_0x3e5b('0x20'),'$lt',_0x3e5b('0x21'),_0x3e5b('0x22'),_0x3e5b('0x23'),_0x3e5b('0x24'),_0x3e5b('0x25'),_0x3e5b('0x26'),_0x3e5b('0x27'),_0x3e5b('0x28'),'$like',_0x3e5b('0x29'),'$iLike',_0x3e5b('0x2a'),'$like',_0x3e5b('0x2b'),_0x3e5b('0x2c'),_0x3e5b('0x2d'),_0x3e5b('0x2e')]);_0xc56a2a[_0x3e5b('0x2f')]=_[_0x3e5b('0x30')](_0x3365dd[_0x3e5b('0x19')],qs[_0x3e5b('0x31')](_0x143040[_0x3e5b('0x1a')][_0x3e5b('0x31')]));_0xc56a2a[_0x3e5b('0x2f')]=_0xc56a2a['attributes'][_0x3e5b('0x32')]?_0xc56a2a[_0x3e5b('0x2f')]:_0x3365dd[_0x3e5b('0x19')];if(!_0x143040[_0x3e5b('0x1a')][_0x3e5b('0x33')](_0x3e5b('0x34'))){_0xc56a2a[_0x3e5b('0xa')]=qs['limit'](_0x143040[_0x3e5b('0x1a')]['limit']);_0xc56a2a['offset']=qs[_0x3e5b('0x8')](_0x143040[_0x3e5b('0x1a')]['offset']);}_0xc56a2a[_0x3e5b('0x35')]=qs[_0x3e5b('0x36')](_0x143040[_0x3e5b('0x1a')][_0x3e5b('0x36')]);_0xc56a2a[_0x3e5b('0x37')]=qs[_0x3e5b('0x1c')](_[_0x3e5b('0x38')](_0x143040[_0x3e5b('0x1a')],_0x3365dd[_0x3e5b('0x1c')]),_0x4b189d);if(_0x143040[_0x3e5b('0x1a')][_0x3e5b('0x39')]){_0xc56a2a[_0x3e5b('0x37')]=_['merge'](_0xc56a2a[_0x3e5b('0x37')],{'$or':_[_0x3e5b('0x13')](_0x4b189d,function(_0x53caa2){if(_0x53caa2['type']!==_0x3e5b('0x3a')){var _0x56d7ef={};_0x56d7ef[_0x53caa2[_0x3e5b('0x11')]]={'$like':'%'+_0x143040[_0x3e5b('0x1a')][_0x3e5b('0x39')]+'%'};return _0x56d7ef;}})});}_0xc56a2a=_[_0x3e5b('0x3b')]({},_0xc56a2a,_0x143040['options']);var _0x18b07f={'where':_0xc56a2a['where']};return db[_0x3e5b('0x14')]['count'](_0x18b07f)['then'](function(_0x48f414){_0x52696c[_0x3e5b('0xb')]=_0x48f414;if(_0x143040[_0x3e5b('0x1a')][_0x3e5b('0x3c')]){_0xc56a2a[_0x3e5b('0x3d')]=[{'all':!![]}];}return db[_0x3e5b('0x14')][_0x3e5b('0x3e')](_0xc56a2a);})['then'](function(_0x5d0c59){_0x52696c['rows']=_0x5d0c59;return _0x52696c;})['then'](respondWithFilteredResult(_0x555002,_0xc56a2a))['catch'](handleError(_0x555002,null));};exports['show']=function(_0x5aad1d,_0x182bc4){var _0x349de0={'raw':!![],'where':{'id':_0x5aad1d[_0x3e5b('0x3f')]['id']}},_0x13a48d={};_0x13a48d[_0x3e5b('0x19')]=_[_0x3e5b('0x1b')](db[_0x3e5b('0x14')][_0x3e5b('0x15')]);_0x13a48d[_0x3e5b('0x1a')]=_[_0x3e5b('0x1b')](_0x5aad1d[_0x3e5b('0x1a')]);_0x13a48d['filters']=_[_0x3e5b('0x30')](_0x13a48d[_0x3e5b('0x19')],_0x13a48d[_0x3e5b('0x1a')]);_0x349de0[_0x3e5b('0x2f')]=_[_0x3e5b('0x30')](_0x13a48d[_0x3e5b('0x19')],qs[_0x3e5b('0x31')](_0x5aad1d[_0x3e5b('0x1a')][_0x3e5b('0x31')]));_0x349de0[_0x3e5b('0x2f')]=_0x349de0[_0x3e5b('0x2f')]['length']?_0x349de0['attributes']:_0x13a48d['model'];if(_0x5aad1d['query'][_0x3e5b('0x3c')]){_0x349de0[_0x3e5b('0x3d')]=[{'all':!![]}];}_0x349de0=_[_0x3e5b('0x3b')]({},_0x349de0,_0x5aad1d[_0x3e5b('0x40')]);return db[_0x3e5b('0x14')][_0x3e5b('0x41')](_0x349de0)[_0x3e5b('0x42')](handleEntityNotFound(_0x182bc4,null))[_0x3e5b('0x42')](respondWithResult(_0x182bc4,null))[_0x3e5b('0x43')](handleError(_0x182bc4,null));};exports[_0x3e5b('0x44')]=function(_0x5d318a,_0x1392f8){return db[_0x3e5b('0x14')][_0x3e5b('0x44')](_0x5d318a[_0x3e5b('0x45')],{})[_0x3e5b('0x42')](respondWithResult(_0x1392f8,0xc9))['catch'](handleError(_0x1392f8,null));};exports['update']=function(_0x495217,_0x1fbd87){if(_0x495217[_0x3e5b('0x45')]['id']){delete _0x495217[_0x3e5b('0x45')]['id'];}return db['CmHopper']['find']({'where':{'id':_0x495217[_0x3e5b('0x3f')]['id']}})[_0x3e5b('0x42')](handleEntityNotFound(_0x1fbd87,null))[_0x3e5b('0x42')](saveUpdates(_0x495217['body'],null))['then'](respondWithResult(_0x1fbd87,null))[_0x3e5b('0x43')](handleError(_0x1fbd87,null));};exports['describe']=function(_0x14b62a,_0x3379a1){return db[_0x3e5b('0x14')][_0x3e5b('0x46')]()[_0x3e5b('0x42')](respondWithResult(_0x3379a1,null))[_0x3e5b('0x43')](handleError(_0x3379a1,null));};exports[_0x3e5b('0x47')]=function(_0x3ea5aa,_0x339852){var _0x4a2ae1;var _0x223185=_0x3ea5aa['params']['id'];return db[_0x3e5b('0x14')][_0x3e5b('0x41')]({'where':{'id':_0x3ea5aa[_0x3e5b('0x3f')]['id']}})[_0x3e5b('0x42')](handleEntityNotFound(_0x339852,null))[_0x3e5b('0x42')](function(_0x3a4f26){if(_0x3a4f26){return _0x3a4f26[_0x3e5b('0x47')]()[_0x3e5b('0x42')](function(_0x2b5d3d){return _0x2b5d3d;});}})[_0x3e5b('0x42')](function(_0xf6ca5b){_0x4a2ae1=_0xf6ca5b;if(_0xf6ca5b){if(_0xf6ca5b[_0x3e5b('0x48')]||_0xf6ca5b[_0x3e5b('0x49')]){return db[_0xf6ca5b['VoiceQueueId']?_0x3e5b('0x4a'):_0x3e5b('0x4b')][_0x3e5b('0x41')]({'where':{'id':_0xf6ca5b[_0x3e5b('0x48')]?_0xf6ca5b[_0x3e5b('0x48')]:_0xf6ca5b[_0x3e5b('0x49')]},'attributes':['id','name'],'raw':!![]});}}})[_0x3e5b('0x42')](function(_0x1cbdf7){var _0x25b166={};if(_0x1cbdf7){_[_0x3e5b('0x3b')](_0x25b166,_[_0x3e5b('0x4c')](_0x4a2ae1[_0x3e5b('0x4d')],[_0x3e5b('0x4e'),_0x3e5b('0x4f'),'id']));_0x25b166['state']=0x15;_0x25b166[_0x3e5b('0x50')]='deleted';_0x25b166['campaign']=_0x1cbdf7[_0x3e5b('0x11')];_0x25b166['membername']=_0x3ea5aa[_0x3e5b('0x51')][_0x3e5b('0x11')];_0x25b166[_0x3e5b('0x52')]=_0x3ea5aa[_0x3e5b('0x51')]['id'];_0x25b166['deleted']=!![];_0x25b166['deletedat']=moment()['format']('YYYY-MM-DD\x20HH:mm:ss');_0x25b166[_0x3e5b('0x53')]=_0x4a2ae1[_0x3e5b('0x54')];_0x25b166[_0x3e5b('0x55')]=_0x4a2ae1[_0x3e5b('0x48')]?_0x3e5b('0x56'):'ivr';return db['CmContact'][_0x3e5b('0x41')]({'where':{'id':_0x25b166[_0x3e5b('0x57')]},'attributes':[_0x3e5b('0x58'),_0x3e5b('0x59')]})[_0x3e5b('0x42')](function(_0x51efbd){if(!_['isNil'](_0x339852)&&!_['isNil'](_0x51efbd['firstName'])){_0x25b166[_0x3e5b('0x5a')]=_0x51efbd[_0x3e5b('0x58')];if(!_[_0x3e5b('0x5b')](_0x51efbd[_0x3e5b('0x59')])){_0x25b166[_0x3e5b('0x5a')]+='\x20'+_0x51efbd[_0x3e5b('0x59')];}}})[_0x3e5b('0x5c')](function(){return db[_0x3e5b('0x5d')]['create'](_0x25b166);});}})[_0x3e5b('0x42')](function(_0x29897b){return db[_0x3e5b('0x5e')][_0x3e5b('0x47')]({'where':{'CmHopperId':_0x223185}});})[_0x3e5b('0x42')](function(){return _0x339852['status'](0xcc)[_0x3e5b('0x5f')]();})['catch'](handleError(_0x339852,null));};exports[_0x3e5b('0x60')]=function(_0x1fd40c,_0x58c41e){var _0x4a7d8e=[];return db['CmContact'][_0x3e5b('0x46')]()['then'](function(_0x1ab942){_0x4a7d8e=_[_0x3e5b('0x1b')](_0x1ab942);return _0x1fd40c[_0x3e5b('0x51')][_0x3e5b('0x61')]({'where':{'type':_0x3e5b('0x62'),'dialActive':!![],'dialMethod':'preview'},'attributes':['id','dialOrderByScheduledAt',_0x3e5b('0x63')],'raw':!![]});})[_0x3e5b('0x42')](function(_0x3f7f71){if(_0x3f7f71&&_0x3f7f71['length']){return db[_0x3e5b('0x64')][_0x3e5b('0x65')](function(_0x32a42f){var _0x1c9526={'active':![],'recallme':![],'scheduledAt':{'$lte':moment()[_0x3e5b('0x66')](_0x3e5b('0x67'))},'VoiceQueueId':{'$in':_[_0x3e5b('0x13')](_0x3f7f71,'id')},'$or':[{'UserId':null},{'UserId':_0x1fd40c[_0x3e5b('0x51')]['id']}]};var _0x3a11a8={'active':![],'recallme':!![],'VoiceQueueId':{'$in':_(_0x3f7f71)[_0x3e5b('0x39')]([_0x3e5b('0x63'),0x0])[_0x3e5b('0x13')]('id')[_0x3e5b('0x68')]()},'$or':[{'UserId':null},{'UserId':_0x1fd40c[_0x3e5b('0x51')]['id']}]};var _0x13204a={'$or':[_0x1c9526,_0x3a11a8]};var _0x2411c3=[];if(_0x1fd40c[_0x3e5b('0x45')][_0x3e5b('0x69')]&&_0x1fd40c['body'][_0x3e5b('0x69')]===_0x3e5b('0x6a')){if(!_['isEmpty'](_0x1fd40c[_0x3e5b('0x45')][_0x3e5b('0x6b')])){_0x13204a['id']={'$in':_0x1fd40c['body']['hopperIds']};}_0x2411c3=[['priority',_0x3e5b('0x6c')],[_0x3e5b('0x6d'),_0x3f7f71[0x0]['dialOrderByScheduledAt']===_0x3e5b('0x6c')?_0x3e5b('0x6e'):'ASC'],db[_0x3e5b('0x64')][_0x3e5b('0x6f')](_0x3e5b('0x70')),['id',_0x3e5b('0x6e')]];}else{if(!_[_0x3e5b('0x71')](_0x1fd40c[_0x3e5b('0x45')][_0x3e5b('0x6b')])){_0x13204a['id']={'$notIn':_0x1fd40c[_0x3e5b('0x45')][_0x3e5b('0x6b')]};}_0x2411c3=[['priority',_0x3e5b('0x6e')],[_0x3e5b('0x6d'),_0x3f7f71[0x0][_0x3e5b('0x72')]],db[_0x3e5b('0x64')][_0x3e5b('0x6f')](_0x3e5b('0x73')),['id',_0x3e5b('0x6c')]];}return db['CmHopper']['findOne']({'attributes':['id',_0x3e5b('0x74'),_0x3e5b('0x54'),'recallme'],'where':_0x13204a,'order':_0x2411c3,'transaction':_0x32a42f,'lock':_0x32a42f[_0x3e5b('0x75')][_0x3e5b('0x76')],'include':[{'model':db[_0x3e5b('0x77')],'as':_0x3e5b('0x78'),'attributes':_0x4a7d8e,'include':[{'model':db[_0x3e5b('0x79')],'as':_0x3e5b('0x7a'),'attributes':['id',_0x3e5b('0x11')]}]},{'model':db['CmList'],'as':_0x3e5b('0x7b'),'attributes':['id',_0x3e5b('0x11')]},{'model':db['VoiceQueue'],'as':'Queue','attributes':['id','name',_0x3e5b('0x7c')]}]})[_0x3e5b('0x42')](function(_0x144738){if(_0x144738){return _0x144738[_0x3e5b('0xe')]({'UserId':_0x1fd40c[_0x3e5b('0x51')]['id']},{'transaction':_0x32a42f});}});});}})[_0x3e5b('0x42')](handleEntityNotFound(_0x58c41e,null))['then'](respondWithResult(_0x58c41e,null))[_0x3e5b('0x43')](handleError(_0x58c41e,null));};exports[_0x3e5b('0x7d')]=function(_0x4ff747,_0x34098c,_0x4da39d){var _0x4f62fb=[];var _0x211e73=_0x4ff747[_0x3e5b('0x3f')]['id'];var _0x487caf=_0x4ff747[_0x3e5b('0x51')]['id'];return db[_0x3e5b('0x77')]['describe']()[_0x3e5b('0x42')](function(_0x185640){_0x4f62fb=_[_0x3e5b('0x1b')](_0x185640);return db[_0x3e5b('0x64')][_0x3e5b('0x65')](function(_0x1541ec){const _0x5df4b1={'id':_0x211e73};return db['CmHopper'][_0x3e5b('0x7e')]({'attributes':['id','scheduledat','recallme'],'where':_0x5df4b1,'transaction':_0x1541ec,'lock':_0x1541ec[_0x3e5b('0x75')][_0x3e5b('0x76')],'include':[{'model':db[_0x3e5b('0x77')],'as':'Contact','attributes':_0x4f62fb,'include':[{'model':db[_0x3e5b('0x79')],'as':'Company','attributes':['id',_0x3e5b('0x11')]}]},{'model':db['CmList'],'as':_0x3e5b('0x7b'),'attributes':['id',_0x3e5b('0x11')]},{'model':db[_0x3e5b('0x4a')],'as':_0x3e5b('0x7f'),'attributes':['id','name',_0x3e5b('0x7c')]}]})['then'](function(_0x2cbf55){if(_0x2cbf55){return _0x2cbf55[_0x3e5b('0xe')]({'UserId':_0x487caf},{'transaction':_0x1541ec});}});});})['then'](handleEntityNotFound(_0x34098c,null))[_0x3e5b('0x42')](respondWithResult(_0x34098c,null))[_0x3e5b('0x43')](handleError(_0x34098c,null));};exports[_0x3e5b('0x80')]=function(_0x5ad011,_0x2d55eb){return _0x5ad011[_0x3e5b('0x51')][_0x3e5b('0x61')]({'where':{'type':'outbound','dialActive':!![],'dialMethod':_0x3e5b('0x81')},'attributes':['id'],'raw':!![]})[_0x3e5b('0x42')](function(_0x4b9774){if(_0x4b9774&&_0x4b9774[_0x3e5b('0x32')]){return db[_0x3e5b('0x14')][_0x3e5b('0xb')]({'where':{'active':![],'recallme':![],'scheduledAt':{'$lte':moment()['format'](_0x3e5b('0x67'))},'VoiceQueueId':{'$in':_[_0x3e5b('0x13')](_0x4b9774,'id')},'$or':[{'UserId':null},{'UserId':_0x5ad011[_0x3e5b('0x51')]['id']}]}});}return 0x0;})[_0x3e5b('0x42')](function(_0x4bf039){if(!_[_0x3e5b('0x5b')](_0x4bf039)&&_['isNumber'](_0x4bf039)){return _0x2d55eb[_0x3e5b('0x6')](0xc8)['json']({'contacts':_0x4bf039});}else{logger[_0x3e5b('0x10')](_0x3e5b('0x82'),'getOpenContacts',0x194,_0x3e5b('0x83'));_0x2d55eb[_0x3e5b('0xf')](0x194);}})['catch'](handleError(_0x2d55eb,null));};exports[_0x3e5b('0x84')]=function(_0x271930,_0x2907dd){var _0x46ce2b=shared['timezones'];var _0x53328b=[];_[_0x3e5b('0x13')](_0x46ce2b,function(_0x37c2ff){_0x53328b[_0x3e5b('0x85')]({'id':_0x37c2ff[_0x3e5b('0x11')],'name':_0x37c2ff[_0x3e5b('0x11')],'utcOffset':_0x37c2ff[_0x3e5b('0x86')]});});return _0x2907dd['status'](0xc8)['json']({'tz':_0x53328b});};exports[_0x3e5b('0x87')]=function(_0x203279,_0x902bb8){var _0x25dec7=shared[_0x3e5b('0x88')];var _0x3f1a82={};if(!_[_0x3e5b('0x5b')](_0x25dec7[_0x203279[_0x3e5b('0x45')]['id']]))_0x3f1a82=_0x25dec7[_0x203279['body']['id']];return _0x902bb8['status'](0xc8)[_0x3e5b('0x7')](_0x3f1a82);};
\ No newline at end of file
+var _0x0fda=['scheduledat','recallme','LOCK','UPDATE','CmCompany','Company','CmList','List','Queue','dialActive','getPreviewRecall','getOpenContacts','isNumber','CmHopper,\x20%s,\x20%s,\x20%s','timezones','push','utcOffset','moment','../../components/parsers/qs','../../config/logger','api','../../config/environment','../../mysqldb','json','offset','undefined','count','status','set','Content-Range','update','sendStatus','error','stack','send','CmHopper','rawAttributes','fieldName','type','key','model','name','query','keys','filters','intersection','concat','$and','$or','$gte','$lt','$ne','$eq','$notBetween','$in','$notILike','$overlap','$contains','$contained','attributes','fields','length','hasOwnProperty','order','sort','where','pick','filter','VIRTUAL','merge','options','includeAll','findAll','then','rows','catch','show','params','include','find','create','body','describe','destroy','CampaignId','VoiceQueueId','VoiceQueue','Campaign','omit','dataValues','createdAt','updatedAt','state','statedesc','deleted','membername','user','UserId','deletedat','YYYY-MM-DD\x20HH:mm:ss','phone','campaigntype','queue','ivr','CmContact','ContactId','firstName','lastName','isNil','calleridname','finally','getVoiceQueues','outbound','preview','dialOrderByScheduledAt','transaction','format','map','dialPreviewAutoRecallMe','value','direction','prev','isEmpty','hopperIds','priority','ASC','scheduledAt','DESC','sequelize','literal','COALESCE(CmHopper.UserId,\x200)\x20ASC','COALESCE(CmHopper.UserId,\x200)\x20DESC','findOne'];(function(_0x2aec52,_0x59d962){var _0x3b8835=function(_0x3e2604){while(--_0x3e2604){_0x2aec52['push'](_0x2aec52['shift']());}};_0x3b8835(++_0x59d962);}(_0x0fda,0x1a0));var _0xa0fd=function(_0x1ba762,_0x425af7){_0x1ba762=_0x1ba762-0x0;var _0x6d4bd3=_0x0fda[_0x1ba762];return _0x6d4bd3;};'use strict';var moment=require(_0xa0fd('0x0'));var _=require('lodash');var qs=require(_0xa0fd('0x1'));var logger=require(_0xa0fd('0x2'))(_0xa0fd('0x3'));var shared=require(_0xa0fd('0x4'));var db=require(_0xa0fd('0x5'))['db'];function respondWithResult(_0xd8e73a,_0x13c734){_0x13c734=_0x13c734||0xc8;return function(_0x574fca){if(_0x574fca){return _0xd8e73a['status'](_0x13c734)[_0xa0fd('0x6')](_0x574fca);}};}function respondWithFilteredResult(_0x4aec58,_0x49b3c1){return function(_0x868183){if(_0x868183){var _0x62b109=typeof _0x49b3c1[_0xa0fd('0x7')]===_0xa0fd('0x8')&&typeof _0x49b3c1['limit']===_0xa0fd('0x8');var _0xe93771=_0x868183[_0xa0fd('0x9')];var _0x322a1a=_0x62b109?0x0:_0x49b3c1['offset'];var _0x31088d=_0x62b109?_0x868183[_0xa0fd('0x9')]:_0x49b3c1[_0xa0fd('0x7')]+_0x49b3c1['limit'];var _0x4409e4;if(_0x31088d>=_0xe93771){_0x31088d=_0xe93771;_0x4409e4=0xc8;}else{_0x4409e4=0xce;}_0x4aec58[_0xa0fd('0xa')](_0x4409e4);return _0x4aec58[_0xa0fd('0xb')](_0xa0fd('0xc'),_0x322a1a+'-'+_0x31088d+'/'+_0xe93771)[_0xa0fd('0x6')](_0x868183);}return null;};}function saveUpdates(_0x4d5c32,_0x490112){return function(_0x32dcee){if(_0x32dcee){return _0x32dcee[_0xa0fd('0xd')](_0x4d5c32)['then'](function(_0x21acc2){return _0x21acc2;});}return null;};}function handleEntityNotFound(_0x8a67a5,_0x11e4eb){return function(_0x1e4a48){if(!_0x1e4a48){_0x8a67a5[_0xa0fd('0xe')](0x194);}return _0x1e4a48;};}function handleError(_0x2e3692,_0x2811c0){_0x2811c0=_0x2811c0||0x1f4;return function(_0x4fe62c){logger[_0xa0fd('0xf')](_0x4fe62c[_0xa0fd('0x10')]);if(_0x4fe62c['name']){delete _0x4fe62c['name'];}_0x2e3692[_0xa0fd('0xa')](_0x2811c0)[_0xa0fd('0x11')](_0x4fe62c);};}exports['index']=function(_0x2b8d15,_0x22a876){var _0x1cb027={},_0x5073a8={},_0x50cde2={'count':0x0,'rows':[]};var _0x46e15a=_['map'](db[_0xa0fd('0x12')][_0xa0fd('0x13')],function(_0x10f64b){return{'name':_0x10f64b[_0xa0fd('0x14')],'type':_0x10f64b[_0xa0fd('0x15')][_0xa0fd('0x16')]};});_0x5073a8[_0xa0fd('0x17')]=_['map'](_0x46e15a,_0xa0fd('0x18'));_0x5073a8[_0xa0fd('0x19')]=_[_0xa0fd('0x1a')](_0x2b8d15[_0xa0fd('0x19')]);_0x5073a8[_0xa0fd('0x1b')]=_[_0xa0fd('0x1c')](_0x5073a8[_0xa0fd('0x17')],_0x5073a8[_0xa0fd('0x19')]);_0x5073a8[_0xa0fd('0x1b')]=_[_0xa0fd('0x1d')](_0x5073a8[_0xa0fd('0x1b')],[_0xa0fd('0x1e'),_0xa0fd('0x1f'),'$gt',_0xa0fd('0x20'),_0xa0fd('0x21'),'$lte',_0xa0fd('0x22'),_0xa0fd('0x23'),'$not','$between',_0xa0fd('0x24'),_0xa0fd('0x25'),'$notIn','$like','$notLike','$iLike',_0xa0fd('0x26'),'$like',_0xa0fd('0x27'),_0xa0fd('0x28'),_0xa0fd('0x29'),'$any']);_0x1cb027[_0xa0fd('0x2a')]=_[_0xa0fd('0x1c')](_0x5073a8[_0xa0fd('0x17')],qs[_0xa0fd('0x2b')](_0x2b8d15[_0xa0fd('0x19')]['fields']));_0x1cb027[_0xa0fd('0x2a')]=_0x1cb027[_0xa0fd('0x2a')][_0xa0fd('0x2c')]?_0x1cb027[_0xa0fd('0x2a')]:_0x5073a8['model'];if(!_0x2b8d15[_0xa0fd('0x19')][_0xa0fd('0x2d')]('nolimit')){_0x1cb027['limit']=qs['limit'](_0x2b8d15[_0xa0fd('0x19')]['limit']);_0x1cb027['offset']=qs[_0xa0fd('0x7')](_0x2b8d15['query'][_0xa0fd('0x7')]);}_0x1cb027[_0xa0fd('0x2e')]=qs[_0xa0fd('0x2f')](_0x2b8d15[_0xa0fd('0x19')][_0xa0fd('0x2f')]);_0x1cb027[_0xa0fd('0x30')]=qs[_0xa0fd('0x1b')](_[_0xa0fd('0x31')](_0x2b8d15['query'],_0x5073a8[_0xa0fd('0x1b')]),_0x46e15a);if(_0x2b8d15['query'][_0xa0fd('0x32')]){_0x1cb027['where']=_['merge'](_0x1cb027[_0xa0fd('0x30')],{'$or':_['map'](_0x46e15a,function(_0x40f8f0){if(_0x40f8f0[_0xa0fd('0x15')]!==_0xa0fd('0x33')){var _0x3c7884={};_0x3c7884[_0x40f8f0['name']]={'$like':'%'+_0x2b8d15[_0xa0fd('0x19')][_0xa0fd('0x32')]+'%'};return _0x3c7884;}})});}_0x1cb027=_[_0xa0fd('0x34')]({},_0x1cb027,_0x2b8d15[_0xa0fd('0x35')]);var _0x2e3cfa={'where':_0x1cb027[_0xa0fd('0x30')]};return db[_0xa0fd('0x12')]['count'](_0x2e3cfa)['then'](function(_0x2aa6a8){_0x50cde2[_0xa0fd('0x9')]=_0x2aa6a8;if(_0x2b8d15[_0xa0fd('0x19')][_0xa0fd('0x36')]){_0x1cb027['include']=[{'all':!![]}];}return db[_0xa0fd('0x12')][_0xa0fd('0x37')](_0x1cb027);})[_0xa0fd('0x38')](function(_0x426ae6){_0x50cde2[_0xa0fd('0x39')]=_0x426ae6;return _0x50cde2;})['then'](respondWithFilteredResult(_0x22a876,_0x1cb027))[_0xa0fd('0x3a')](handleError(_0x22a876,null));};exports[_0xa0fd('0x3b')]=function(_0x558f67,_0x48125b){var _0x27082a={'raw':!![],'where':{'id':_0x558f67[_0xa0fd('0x3c')]['id']}},_0x163023={};_0x163023[_0xa0fd('0x17')]=_[_0xa0fd('0x1a')](db[_0xa0fd('0x12')][_0xa0fd('0x13')]);_0x163023[_0xa0fd('0x19')]=_[_0xa0fd('0x1a')](_0x558f67[_0xa0fd('0x19')]);_0x163023[_0xa0fd('0x1b')]=_[_0xa0fd('0x1c')](_0x163023[_0xa0fd('0x17')],_0x163023[_0xa0fd('0x19')]);_0x27082a[_0xa0fd('0x2a')]=_['intersection'](_0x163023['model'],qs['fields'](_0x558f67[_0xa0fd('0x19')][_0xa0fd('0x2b')]));_0x27082a[_0xa0fd('0x2a')]=_0x27082a['attributes'][_0xa0fd('0x2c')]?_0x27082a[_0xa0fd('0x2a')]:_0x163023[_0xa0fd('0x17')];if(_0x558f67['query'][_0xa0fd('0x36')]){_0x27082a[_0xa0fd('0x3d')]=[{'all':!![]}];}_0x27082a=_[_0xa0fd('0x34')]({},_0x27082a,_0x558f67[_0xa0fd('0x35')]);return db[_0xa0fd('0x12')][_0xa0fd('0x3e')](_0x27082a)['then'](handleEntityNotFound(_0x48125b,null))[_0xa0fd('0x38')](respondWithResult(_0x48125b,null))[_0xa0fd('0x3a')](handleError(_0x48125b,null));};exports[_0xa0fd('0x3f')]=function(_0x2498da,_0x324206){return db[_0xa0fd('0x12')]['create'](_0x2498da[_0xa0fd('0x40')],{})[_0xa0fd('0x38')](respondWithResult(_0x324206,0xc9))[_0xa0fd('0x3a')](handleError(_0x324206,null));};exports[_0xa0fd('0xd')]=function(_0x16d0cc,_0x508747){if(_0x16d0cc['body']['id']){delete _0x16d0cc[_0xa0fd('0x40')]['id'];}return db[_0xa0fd('0x12')][_0xa0fd('0x3e')]({'where':{'id':_0x16d0cc[_0xa0fd('0x3c')]['id']}})[_0xa0fd('0x38')](handleEntityNotFound(_0x508747,null))['then'](saveUpdates(_0x16d0cc[_0xa0fd('0x40')],null))[_0xa0fd('0x38')](respondWithResult(_0x508747,null))[_0xa0fd('0x3a')](handleError(_0x508747,null));};exports[_0xa0fd('0x41')]=function(_0x93d528,_0x22504a){return db['CmHopper']['describe']()['then'](respondWithResult(_0x22504a,null))[_0xa0fd('0x3a')](handleError(_0x22504a,null));};exports['destroy']=function(_0x4e4ce4,_0xcf725e){var _0x504a0a;var _0x357324=_0x4e4ce4[_0xa0fd('0x3c')]['id'];return db['CmHopper']['find']({'where':{'id':_0x4e4ce4[_0xa0fd('0x3c')]['id']}})[_0xa0fd('0x38')](handleEntityNotFound(_0xcf725e,null))[_0xa0fd('0x38')](function(_0x167503){if(_0x167503){return _0x167503[_0xa0fd('0x42')]()[_0xa0fd('0x38')](function(_0x5268ba){return _0x5268ba;});}})['then'](function(_0x50382c){_0x504a0a=_0x50382c;if(_0x50382c){if(_0x50382c['VoiceQueueId']||_0x50382c[_0xa0fd('0x43')]){return db[_0x50382c[_0xa0fd('0x44')]?_0xa0fd('0x45'):_0xa0fd('0x46')][_0xa0fd('0x3e')]({'where':{'id':_0x50382c['VoiceQueueId']?_0x50382c['VoiceQueueId']:_0x50382c['CampaignId']},'attributes':['id','name'],'raw':!![]});}}})['then'](function(_0x386dfe){var _0x4238e4={};if(_0x386dfe){_[_0xa0fd('0x34')](_0x4238e4,_[_0xa0fd('0x47')](_0x504a0a[_0xa0fd('0x48')],[_0xa0fd('0x49'),_0xa0fd('0x4a'),'id']));_0x4238e4[_0xa0fd('0x4b')]=0x15;_0x4238e4[_0xa0fd('0x4c')]=_0xa0fd('0x4d');_0x4238e4['campaign']=_0x386dfe['name'];_0x4238e4[_0xa0fd('0x4e')]=_0x4e4ce4[_0xa0fd('0x4f')][_0xa0fd('0x18')];_0x4238e4[_0xa0fd('0x50')]=_0x4e4ce4['user']['id'];_0x4238e4[_0xa0fd('0x4d')]=!![];_0x4238e4[_0xa0fd('0x51')]=moment()['format'](_0xa0fd('0x52'));_0x4238e4['calleridnum']=_0x504a0a[_0xa0fd('0x53')];_0x4238e4[_0xa0fd('0x54')]=_0x504a0a['VoiceQueueId']?_0xa0fd('0x55'):_0xa0fd('0x56');return db[_0xa0fd('0x57')][_0xa0fd('0x3e')]({'where':{'id':_0x4238e4[_0xa0fd('0x58')]},'attributes':[_0xa0fd('0x59'),_0xa0fd('0x5a')]})[_0xa0fd('0x38')](function(_0x5e0440){if(!_[_0xa0fd('0x5b')](_0xcf725e)&&!_['isNil'](_0x5e0440[_0xa0fd('0x59')])){_0x4238e4[_0xa0fd('0x5c')]=_0x5e0440[_0xa0fd('0x59')];if(!_[_0xa0fd('0x5b')](_0x5e0440[_0xa0fd('0x5a')])){_0x4238e4['calleridname']+='\x20'+_0x5e0440[_0xa0fd('0x5a')];}}})[_0xa0fd('0x5d')](function(){return db['CmHopperFinal'][_0xa0fd('0x3f')](_0x4238e4);});}})[_0xa0fd('0x38')](function(_0xfd99a9){return db['CmHopperAdditionalPhone'][_0xa0fd('0x42')]({'where':{'CmHopperId':_0x357324}});})['then'](function(){return _0xcf725e[_0xa0fd('0xa')](0xcc)['end']();})[_0xa0fd('0x3a')](handleError(_0xcf725e,null));};exports['getPreview']=function(_0x1a4da0,_0x62c3e7){var _0x3f9d1e=[];return db[_0xa0fd('0x57')][_0xa0fd('0x41')]()[_0xa0fd('0x38')](function(_0x38076b){_0x3f9d1e=_['keys'](_0x38076b);return _0x1a4da0[_0xa0fd('0x4f')][_0xa0fd('0x5e')]({'where':{'type':_0xa0fd('0x5f'),'dialActive':!![],'dialMethod':_0xa0fd('0x60')},'attributes':['id',_0xa0fd('0x61'),'dialPreviewAutoRecallMe'],'raw':!![]});})['then'](function(_0x4ed729){if(_0x4ed729&&_0x4ed729[_0xa0fd('0x2c')]){return db['sequelize'][_0xa0fd('0x62')](function(_0x589433){var _0x4524a3={'active':![],'recallme':![],'scheduledAt':{'$lte':moment()[_0xa0fd('0x63')](_0xa0fd('0x52'))},'VoiceQueueId':{'$in':_[_0xa0fd('0x64')](_0x4ed729,'id')},'$or':[{'UserId':null},{'UserId':_0x1a4da0[_0xa0fd('0x4f')]['id']}]};var _0x5c3efa={'active':![],'recallme':!![],'VoiceQueueId':{'$in':_(_0x4ed729)[_0xa0fd('0x32')]([_0xa0fd('0x65'),0x0])[_0xa0fd('0x64')]('id')[_0xa0fd('0x66')]()},'$or':[{'UserId':null},{'UserId':_0x1a4da0[_0xa0fd('0x4f')]['id']}]};var _0x26bd48={'$or':[_0x4524a3,_0x5c3efa]};var _0x527e93=[];if(_0x1a4da0['body'][_0xa0fd('0x67')]&&_0x1a4da0[_0xa0fd('0x40')][_0xa0fd('0x67')]===_0xa0fd('0x68')){if(!_[_0xa0fd('0x69')](_0x1a4da0[_0xa0fd('0x40')][_0xa0fd('0x6a')])){_0x26bd48['id']={'$in':_0x1a4da0[_0xa0fd('0x40')]['hopperIds']};}_0x527e93=[[_0xa0fd('0x6b'),_0xa0fd('0x6c')],[_0xa0fd('0x6d'),_0x4ed729[0x0][_0xa0fd('0x61')]===_0xa0fd('0x6c')?_0xa0fd('0x6e'):_0xa0fd('0x6c')],db[_0xa0fd('0x6f')][_0xa0fd('0x70')](_0xa0fd('0x71')),['id',_0xa0fd('0x6e')]];}else{if(!_[_0xa0fd('0x69')](_0x1a4da0['body'][_0xa0fd('0x6a')])){_0x26bd48['id']={'$notIn':_0x1a4da0[_0xa0fd('0x40')][_0xa0fd('0x6a')]};}_0x527e93=[[_0xa0fd('0x6b'),_0xa0fd('0x6e')],[_0xa0fd('0x6d'),_0x4ed729[0x0][_0xa0fd('0x61')]],db[_0xa0fd('0x6f')][_0xa0fd('0x70')](_0xa0fd('0x72')),['id','ASC']];}return db[_0xa0fd('0x12')][_0xa0fd('0x73')]({'attributes':['id',_0xa0fd('0x74'),_0xa0fd('0x53'),_0xa0fd('0x75')],'where':_0x26bd48,'order':_0x527e93,'transaction':_0x589433,'lock':_0x589433[_0xa0fd('0x76')][_0xa0fd('0x77')],'include':[{'model':db[_0xa0fd('0x57')],'as':'Contact','attributes':_0x3f9d1e,'include':[{'model':db[_0xa0fd('0x78')],'as':_0xa0fd('0x79'),'attributes':['id','name']}]},{'model':db[_0xa0fd('0x7a')],'as':_0xa0fd('0x7b'),'attributes':['id',_0xa0fd('0x18')]},{'model':db[_0xa0fd('0x45')],'as':_0xa0fd('0x7c'),'attributes':['id','name',_0xa0fd('0x7d')]}]})[_0xa0fd('0x38')](function(_0xccdeca){if(_0xccdeca){return _0xccdeca[_0xa0fd('0xd')]({'UserId':_0x1a4da0[_0xa0fd('0x4f')]['id']},{'transaction':_0x589433});}});});}})[_0xa0fd('0x38')](handleEntityNotFound(_0x62c3e7,null))[_0xa0fd('0x38')](respondWithResult(_0x62c3e7,null))[_0xa0fd('0x3a')](handleError(_0x62c3e7,null));};exports[_0xa0fd('0x7e')]=function(_0x4407a3,_0x3661f6,_0x245012){var _0x36452c=[];var _0x7d5b1d=_0x4407a3[_0xa0fd('0x3c')]['id'];var _0x1f3851=_0x4407a3[_0xa0fd('0x4f')]['id'];return db[_0xa0fd('0x57')][_0xa0fd('0x41')]()['then'](function(_0x2075cb){_0x36452c=_[_0xa0fd('0x1a')](_0x2075cb);return db[_0xa0fd('0x6f')][_0xa0fd('0x62')](function(_0x5551ff){const _0xeaddf={'id':_0x7d5b1d};return db[_0xa0fd('0x12')][_0xa0fd('0x73')]({'attributes':['id',_0xa0fd('0x74'),_0xa0fd('0x75')],'where':_0xeaddf,'transaction':_0x5551ff,'lock':_0x5551ff['LOCK'][_0xa0fd('0x77')],'include':[{'model':db[_0xa0fd('0x57')],'as':'Contact','attributes':_0x36452c,'include':[{'model':db['CmCompany'],'as':_0xa0fd('0x79'),'attributes':['id','name']}]},{'model':db['CmList'],'as':_0xa0fd('0x7b'),'attributes':['id',_0xa0fd('0x18')]},{'model':db['VoiceQueue'],'as':_0xa0fd('0x7c'),'attributes':['id',_0xa0fd('0x18'),_0xa0fd('0x7d')]}]})[_0xa0fd('0x38')](function(_0x2aa91d){if(_0x2aa91d){return _0x2aa91d['update']({'UserId':_0x1f3851},{'transaction':_0x5551ff});}});});})[_0xa0fd('0x38')](handleEntityNotFound(_0x3661f6,null))[_0xa0fd('0x38')](respondWithResult(_0x3661f6,null))['catch'](handleError(_0x3661f6,null));};exports[_0xa0fd('0x7f')]=function(_0x37eb12,_0x6431a){return _0x37eb12['user'][_0xa0fd('0x5e')]({'where':{'type':'outbound','dialActive':!![],'dialMethod':_0xa0fd('0x60')},'attributes':['id'],'raw':!![]})[_0xa0fd('0x38')](function(_0xe9600b){if(_0xe9600b&&_0xe9600b[_0xa0fd('0x2c')]){return db['CmHopper'][_0xa0fd('0x9')]({'where':{'active':![],'recallme':![],'scheduledAt':{'$lte':moment()[_0xa0fd('0x63')](_0xa0fd('0x52'))},'VoiceQueueId':{'$in':_[_0xa0fd('0x64')](_0xe9600b,'id')},'$or':[{'UserId':null},{'UserId':_0x37eb12[_0xa0fd('0x4f')]['id']}]}});}return 0x0;})[_0xa0fd('0x38')](function(_0x59e347){if(!_[_0xa0fd('0x5b')](_0x59e347)&&_[_0xa0fd('0x80')](_0x59e347)){return _0x6431a[_0xa0fd('0xa')](0xc8)[_0xa0fd('0x6')]({'contacts':_0x59e347});}else{logger[_0xa0fd('0xf')](_0xa0fd('0x81'),'getOpenContacts',0x194,'entity\x20not\x20found');_0x6431a[_0xa0fd('0xe')](0x194);}})[_0xa0fd('0x3a')](handleError(_0x6431a,null));};exports['getTimezones']=function(_0x1888d4,_0x42a27d){var _0x1bdcb=shared[_0xa0fd('0x82')];var _0x4ebc93=[];_[_0xa0fd('0x64')](_0x1bdcb,function(_0x1bcad3){_0x4ebc93[_0xa0fd('0x83')]({'id':_0x1bcad3[_0xa0fd('0x18')],'name':_0x1bcad3['name'],'utcOffset':_0x1bcad3[_0xa0fd('0x84')]});});return _0x42a27d[_0xa0fd('0xa')](0xc8)[_0xa0fd('0x6')]({'tz':_0x4ebc93});};exports['getTimezone']=function(_0x1ef642,_0x23e557){var _0x4c3da0=shared['timezones'];var _0xe8e94c={};if(!_[_0xa0fd('0x5b')](_0x4c3da0[_0x1ef642[_0xa0fd('0x40')]['id']]))_0xe8e94c=_0x4c3da0[_0x1ef642[_0xa0fd('0x40')]['id']];return _0x23e557['status'](0xc8)['json'](_0xe8e94c);};
\ No newline at end of file