Built motion from commit da24aabd.|2.6.20
[motion2.git] / server / api / cmHopper / cmHopper.controller.js
index 40a2d25..444f044 100644 (file)
@@ -15,4 +15,4 @@
 // * treaties. The SOFTWARE PRODUCT is licensed, not sold.                        *
 // *                                                                       *
 // *************************************************************************
-var _0xf44a=['error','stack','name','send','index','CmHopper','rawAttributes','fieldName','type','key','model','map','query','filters','intersection','concat','$and','$or','$gt','$lt','$lte','$ne','$not','$between','$notBetween','$in','$notIn','$like','$iLike','$notILike','$overlap','$contains','$contained','$any','attributes','fields','nolimit','order','sort','filter','where','merge','VIRTUAL','options','includeAll','include','findAll','rows','catch','show','params','keys','length','find','create','body','describe','VoiceQueueId','CampaignId','VoiceQueue','Campaign','omit','dataValues','statedesc','user','UserId','deleted','deletedat','format','calleridnum','phone','queue','lastName','isNil','firstName','calleridname','finally','CmHopperFinal','CmContact','outbound','preview','sequelize','transaction','YYYY-MM-DD\x20HH:mm:ss','direction','prev','hopperIds','priority','scheduledAt','dialOrderByScheduledAt','ASC','literal','DESC','isEmpty','COALESCE(CmHopper.UserId,\x200)\x20DESC','findOne','scheduledat','LOCK','UPDATE','Contact','CmCompany','Company','CmList','Queue','dialActive','getOpenContacts','getVoiceQueues','CmHopper,\x20%s,\x20%s,\x20%s','entity\x20not\x20found','rimraf','zip-dir','fast-json-patch','request-promise','moment','bluebird','mustache','path','sox','to-csv','lodash','squel','crypto','jsforce','querystring','papaparse','../../components/parsers/advancedSearch','api','../../config/utils','../../mysqldb','sendStatus','status','end','json','count','limit','set','reject','save','update','destroy','then'];(function(_0x2cbc47,_0x2daf86){var _0x2b429e=function(_0x2e5582){while(--_0x2e5582){_0x2cbc47['push'](_0x2cbc47['shift']());}};_0x2b429e(++_0x2daf86);}(_0xf44a,0x6d));var _0xaf44=function(_0x20e196,_0x49e141){_0x20e196=_0x20e196-0x0;var _0x986fc7=_0xf44a[_0x20e196];return _0x986fc7;};'use strict';var pdf=require('html-pdf');var emlformat=require('eml-format');var rimraf=require(_0xaf44('0x0'));var zipdir=require(_0xaf44('0x1'));var jsonpatch=require(_0xaf44('0x2'));var rp=require(_0xaf44('0x3'));var moment=require(_0xaf44('0x4'));var BPromise=require(_0xaf44('0x5'));var Mustache=require(_0xaf44('0x6'));var util=require('util');var path=require(_0xaf44('0x7'));var sox=require(_0xaf44('0x8'));var csv=require(_0xaf44('0x9'));var ejs=require('ejs');var fs=require('fs');var _=require(_0xaf44('0xa'));var squel=require(_0xaf44('0xb'));var crypto=require(_0xaf44('0xc'));var jsforce=require(_0xaf44('0xd'));var deskjs=require('desk.js');var toCsv=require(_0xaf44('0x9'));var querystring=require(_0xaf44('0xe'));var Papa=require(_0xaf44('0xf'));var Redis=require('ioredis');var authService=require('../../components/auth/service');var qs=require('../../components/parsers/qs');var as=require(_0xaf44('0x10'));var hardwareService=require('../../config/license/hardware');var logger=require('../../config/logger')(_0xaf44('0x11'));var utils=require(_0xaf44('0x12'));var config=require('../../config/environment');var db=require(_0xaf44('0x13'))['db'];function respondWithStatusCode(_0x387f4d,_0x16a91d){_0x16a91d=_0x16a91d||0xcc;return function(_0x4233a9){if(_0x4233a9){return _0x387f4d[_0xaf44('0x14')](_0x16a91d);}return _0x387f4d[_0xaf44('0x15')](_0x16a91d)[_0xaf44('0x16')]();};}function respondWithResult(_0x37060b,_0x1ee1fd){_0x1ee1fd=_0x1ee1fd||0xc8;return function(_0x2be3da){if(_0x2be3da){return _0x37060b[_0xaf44('0x15')](_0x1ee1fd)[_0xaf44('0x17')](_0x2be3da);}};}function respondWithFilteredResult(_0x1348e8,_0x123b9d){return function(_0x2275fb){if(_0x2275fb){var _0x1a3ac7=_0x2275fb[_0xaf44('0x18')],_0x1c1c41=_0x123b9d['offset'],_0x29f371=_0x123b9d['offset']+_0x123b9d[_0xaf44('0x19')],_0xa16d74;if(_0x29f371>=_0x1a3ac7){_0x29f371=_0x1a3ac7;_0xa16d74=0xc8;}else{_0xa16d74=0xce;}_0x1348e8[_0xaf44('0x15')](_0xa16d74);return _0x1348e8[_0xaf44('0x1a')]('Content-Range',_0x1c1c41+'-'+_0x29f371+'/'+_0x1a3ac7)[_0xaf44('0x17')](_0x2275fb);}return null;};}function patchUpdates(_0x202179){return function(_0x49fcb7){try{jsonpatch['apply'](_0x49fcb7,_0x202179,!![]);}catch(_0x3f73c6){return BPromise[_0xaf44('0x1b')](_0x3f73c6);}return _0x49fcb7[_0xaf44('0x1c')]();};}function saveUpdates(_0x1a800f,_0x4b2f5e){return function(_0x4282eb){if(_0x4282eb){return _0x4282eb[_0xaf44('0x1d')](_0x1a800f)['then'](function(_0x5c09a1){return _0x5c09a1;});}return null;};}function removeEntity(_0x48d0af,_0x2b7912){return function(_0x12526c){if(_0x12526c){return _0x12526c[_0xaf44('0x1e')]()[_0xaf44('0x1f')](function(){_0x48d0af['status'](0xcc)['end']();});}};}function handleEntityNotFound(_0x54e0ce,_0x35f44c){return function(_0x157279){if(!_0x157279){_0x54e0ce[_0xaf44('0x14')](0x194);}return _0x157279;};}function handleError(_0x587f71,_0xf1d3f3){_0xf1d3f3=_0xf1d3f3||0x1f4;return function(_0x5cc7ff){logger[_0xaf44('0x20')](_0x5cc7ff[_0xaf44('0x21')]);if(_0x5cc7ff[_0xaf44('0x22')]){delete _0x5cc7ff[_0xaf44('0x22')];}_0x587f71[_0xaf44('0x15')](_0xf1d3f3)[_0xaf44('0x23')](_0x5cc7ff);};}exports[_0xaf44('0x24')]=function(_0x1dc3ce,_0x212085){var _0x3a340e={},_0x384e68={},_0x2d2837={'count':0x0,'rows':[]};var _0x1782ef=_['map'](db[_0xaf44('0x25')][_0xaf44('0x26')],function(_0x3e8ed9){return{'name':_0x3e8ed9[_0xaf44('0x27')],'type':_0x3e8ed9[_0xaf44('0x28')][_0xaf44('0x29')]};});_0x384e68[_0xaf44('0x2a')]=_[_0xaf44('0x2b')](_0x1782ef,'name');_0x384e68[_0xaf44('0x2c')]=_['keys'](_0x1dc3ce['query']);_0x384e68[_0xaf44('0x2d')]=_[_0xaf44('0x2e')](_0x384e68[_0xaf44('0x2a')],_0x384e68[_0xaf44('0x2c')]);_0x384e68[_0xaf44('0x2d')]=_[_0xaf44('0x2f')](_0x384e68[_0xaf44('0x2d')],[_0xaf44('0x30'),_0xaf44('0x31'),_0xaf44('0x32'),'$gte',_0xaf44('0x33'),_0xaf44('0x34'),_0xaf44('0x35'),'$eq',_0xaf44('0x36'),_0xaf44('0x37'),_0xaf44('0x38'),_0xaf44('0x39'),_0xaf44('0x3a'),_0xaf44('0x3b'),'$notLike',_0xaf44('0x3c'),_0xaf44('0x3d'),_0xaf44('0x3b'),_0xaf44('0x3e'),_0xaf44('0x3f'),_0xaf44('0x40'),_0xaf44('0x41')]);_0x3a340e[_0xaf44('0x42')]=_[_0xaf44('0x2e')](_0x384e68[_0xaf44('0x2a')],qs[_0xaf44('0x43')](_0x1dc3ce[_0xaf44('0x2c')]['fields']));_0x3a340e[_0xaf44('0x42')]=_0x3a340e[_0xaf44('0x42')]['length']?_0x3a340e[_0xaf44('0x42')]:_0x384e68[_0xaf44('0x2a')];if(!_0x1dc3ce['query']['hasOwnProperty'](_0xaf44('0x44'))){_0x3a340e[_0xaf44('0x19')]=qs[_0xaf44('0x19')](_0x1dc3ce['query']['limit']);_0x3a340e['offset']=qs['offset'](_0x1dc3ce[_0xaf44('0x2c')]['offset']);}_0x3a340e[_0xaf44('0x45')]=qs[_0xaf44('0x46')](_0x1dc3ce['query'][_0xaf44('0x46')]);_0x3a340e['where']=qs['filters'](_['pick'](_0x1dc3ce['query'],_0x384e68[_0xaf44('0x2d')]));if(_0x1dc3ce['query'][_0xaf44('0x47')]){_0x3a340e[_0xaf44('0x48')]=_[_0xaf44('0x49')](_0x3a340e[_0xaf44('0x48')],{'$or':_[_0xaf44('0x2b')](_0x1782ef,function(_0xdcd2a7){if(_0xdcd2a7[_0xaf44('0x28')]!==_0xaf44('0x4a')){var _0x5d2ec8={};_0x5d2ec8[_0xdcd2a7[_0xaf44('0x22')]]={'$like':'%'+_0x1dc3ce['query'][_0xaf44('0x47')]+'%'};return _0x5d2ec8;}})});}_0x3a340e=_[_0xaf44('0x49')]({},_0x3a340e,_0x1dc3ce[_0xaf44('0x4b')]);var _0x4e4058={'where':_0x3a340e[_0xaf44('0x48')]};return db['CmHopper'][_0xaf44('0x18')](_0x4e4058)['then'](function(_0x199233){_0x2d2837[_0xaf44('0x18')]=_0x199233;if(_0x1dc3ce[_0xaf44('0x2c')][_0xaf44('0x4c')]){_0x3a340e[_0xaf44('0x4d')]=[{'all':!![]}];}return db[_0xaf44('0x25')][_0xaf44('0x4e')](_0x3a340e);})['then'](function(_0x4a06ec){_0x2d2837[_0xaf44('0x4f')]=_0x4a06ec;return _0x2d2837;})['then'](respondWithFilteredResult(_0x212085,_0x3a340e))[_0xaf44('0x50')](handleError(_0x212085,null));};exports[_0xaf44('0x51')]=function(_0x32c71e,_0x189324){var _0x4b0dff={'raw':!![],'where':{'id':_0x32c71e[_0xaf44('0x52')]['id']}},_0x410783={};_0x410783['model']=_['keys'](db[_0xaf44('0x25')]['rawAttributes']);_0x410783['query']=_[_0xaf44('0x53')](_0x32c71e[_0xaf44('0x2c')]);_0x410783[_0xaf44('0x2d')]=_['intersection'](_0x410783[_0xaf44('0x2a')],_0x410783[_0xaf44('0x2c')]);_0x4b0dff[_0xaf44('0x42')]=_[_0xaf44('0x2e')](_0x410783[_0xaf44('0x2a')],qs[_0xaf44('0x43')](_0x32c71e['query'][_0xaf44('0x43')]));_0x4b0dff[_0xaf44('0x42')]=_0x4b0dff[_0xaf44('0x42')][_0xaf44('0x54')]?_0x4b0dff[_0xaf44('0x42')]:_0x410783[_0xaf44('0x2a')];if(_0x32c71e[_0xaf44('0x2c')][_0xaf44('0x4c')]){_0x4b0dff['include']=[{'all':!![]}];}_0x4b0dff=_[_0xaf44('0x49')]({},_0x4b0dff,_0x32c71e[_0xaf44('0x4b')]);return db['CmHopper'][_0xaf44('0x55')](_0x4b0dff)[_0xaf44('0x1f')](handleEntityNotFound(_0x189324,null))[_0xaf44('0x1f')](respondWithResult(_0x189324,null))['catch'](handleError(_0x189324,null));};exports[_0xaf44('0x56')]=function(_0x2232dc,_0x5aeb43){return db[_0xaf44('0x25')][_0xaf44('0x56')](_0x2232dc[_0xaf44('0x57')],{})['then'](respondWithResult(_0x5aeb43,0xc9))[_0xaf44('0x50')](handleError(_0x5aeb43,null));};exports[_0xaf44('0x1d')]=function(_0x11dff7,_0xbd6b48){if(_0x11dff7[_0xaf44('0x57')]['id']){delete _0x11dff7[_0xaf44('0x57')]['id'];}return db[_0xaf44('0x25')]['find']({'where':{'id':_0x11dff7['params']['id']}})[_0xaf44('0x1f')](handleEntityNotFound(_0xbd6b48,null))[_0xaf44('0x1f')](saveUpdates(_0x11dff7['body'],null))[_0xaf44('0x1f')](respondWithResult(_0xbd6b48,null))['catch'](handleError(_0xbd6b48,null));};exports[_0xaf44('0x58')]=function(_0x2802e3,_0x404a80){return db[_0xaf44('0x25')][_0xaf44('0x58')]()[_0xaf44('0x1f')](respondWithResult(_0x404a80,null))[_0xaf44('0x50')](handleError(_0x404a80,null));};exports[_0xaf44('0x1e')]=function(_0x17d60e,_0x24ea9d){var _0x19aa26;return db['CmHopper']['find']({'where':{'id':_0x17d60e['params']['id']}})['then'](handleEntityNotFound(_0x24ea9d,null))[_0xaf44('0x1f')](function(_0x1c4437){if(_0x1c4437){return _0x1c4437[_0xaf44('0x1e')]()['then'](function(_0x460c57){return _0x460c57;});}})['then'](function(_0x429379){_0x19aa26=_0x429379;if(_0x429379){if(_0x429379[_0xaf44('0x59')]||_0x429379[_0xaf44('0x5a')]){return db[_0x429379[_0xaf44('0x59')]?_0xaf44('0x5b'):_0xaf44('0x5c')][_0xaf44('0x55')]({'where':{'id':_0x429379[_0xaf44('0x59')]?_0x429379[_0xaf44('0x59')]:_0x429379[_0xaf44('0x5a')]},'attributes':['id',_0xaf44('0x22')],'raw':!![]});}}})[_0xaf44('0x1f')](function(_0x64cd78){var _0x5d0e92={};if(_0x64cd78){_[_0xaf44('0x49')](_0x5d0e92,_[_0xaf44('0x5d')](_0x19aa26[_0xaf44('0x5e')],['createdAt','updatedAt','id']));_0x5d0e92['state']=0x15;_0x5d0e92[_0xaf44('0x5f')]='deleted';_0x5d0e92['campaign']=_0x64cd78[_0xaf44('0x22')];_0x5d0e92['membername']=_0x17d60e[_0xaf44('0x60')][_0xaf44('0x22')];_0x5d0e92[_0xaf44('0x61')]=_0x17d60e[_0xaf44('0x60')]['id'];_0x5d0e92[_0xaf44('0x62')]=!![];_0x5d0e92[_0xaf44('0x63')]=moment()[_0xaf44('0x64')]('YYYY-MM-DD\x20HH:mm:ss');_0x5d0e92[_0xaf44('0x65')]=_0x19aa26[_0xaf44('0x66')];_0x5d0e92['campaigntype']=_0x19aa26[_0xaf44('0x59')]?_0xaf44('0x67'):'ivr';return db['CmContact'][_0xaf44('0x55')]({'where':{'id':_0x5d0e92['ContactId']},'attributes':['firstName',_0xaf44('0x68')]})[_0xaf44('0x1f')](function(_0xcdd315){if(!_[_0xaf44('0x69')](_0x24ea9d)&&!_[_0xaf44('0x69')](_0xcdd315[_0xaf44('0x6a')])){_0x5d0e92['calleridname']=_0xcdd315['firstName'];if(!_[_0xaf44('0x69')](_0xcdd315[_0xaf44('0x68')])){_0x5d0e92[_0xaf44('0x6b')]+='\x20'+_0xcdd315[_0xaf44('0x68')];}}})[_0xaf44('0x6c')](function(){return db[_0xaf44('0x6d')]['create'](_0x5d0e92);});}})['then'](function(){return _0x24ea9d['status'](0xcc)[_0xaf44('0x16')]();})[_0xaf44('0x50')](handleError(_0x24ea9d,null));};exports['getPreview']=function(_0x2c6b59,_0x717cc3,_0xa91c1){var _0x192f56=[];return db[_0xaf44('0x6e')]['describe']()[_0xaf44('0x1f')](function(_0x5d01ed){_0x192f56=_[_0xaf44('0x53')](_0x5d01ed);return _0x2c6b59[_0xaf44('0x60')]['getVoiceQueues']({'where':{'type':_0xaf44('0x6f'),'dialActive':!![],'dialMethod':_0xaf44('0x70')},'attributes':['id','dialOrderByScheduledAt'],'raw':!![]});})[_0xaf44('0x1f')](function(_0x18ada4){if(_0x18ada4&&_0x18ada4[_0xaf44('0x54')]){return db[_0xaf44('0x71')][_0xaf44('0x72')](function(_0xfcf175){var _0x10652d={'active':![],'recallme':![],'scheduledAt':{'$lte':moment()[_0xaf44('0x64')](_0xaf44('0x73'))},'VoiceQueueId':{'$in':_[_0xaf44('0x2b')](_0x18ada4,'id')},'$or':[{'UserId':null},{'UserId':_0x2c6b59[_0xaf44('0x60')]['id']}]};var _0xf43f9e=[];if(_0x2c6b59[_0xaf44('0x57')][_0xaf44('0x74')]&&_0x2c6b59[_0xaf44('0x57')]['direction']===_0xaf44('0x75')){if(!_['isEmpty'](_0x2c6b59['body'][_0xaf44('0x76')])){_0x10652d['id']={'$in':_0x2c6b59[_0xaf44('0x57')][_0xaf44('0x76')]};}_0xf43f9e=[[_0xaf44('0x77'),'ASC'],[_0xaf44('0x78'),_0x18ada4[0x0][_0xaf44('0x79')]===_0xaf44('0x7a')?'DESC':_0xaf44('0x7a')],db[_0xaf44('0x71')][_0xaf44('0x7b')]('COALESCE(CmHopper.UserId,\x200)\x20ASC'),['id',_0xaf44('0x7c')]];}else{if(!_[_0xaf44('0x7d')](_0x2c6b59[_0xaf44('0x57')]['hopperIds'])){_0x10652d['id']={'$notIn':_0x2c6b59[_0xaf44('0x57')][_0xaf44('0x76')]};}_0xf43f9e=[['priority',_0xaf44('0x7c')],[_0xaf44('0x78'),_0x18ada4[0x0][_0xaf44('0x79')]],db[_0xaf44('0x71')][_0xaf44('0x7b')](_0xaf44('0x7e')),['id',_0xaf44('0x7a')]];}return db[_0xaf44('0x25')][_0xaf44('0x7f')]({'attributes':['id',_0xaf44('0x80')],'where':_0x10652d,'order':_0xf43f9e,'transaction':_0xfcf175,'lock':_0xfcf175[_0xaf44('0x81')][_0xaf44('0x82')],'include':[{'model':db['CmContact'],'as':_0xaf44('0x83'),'attributes':_0x192f56,'include':[{'model':db[_0xaf44('0x84')],'as':_0xaf44('0x85'),'attributes':['id',_0xaf44('0x22')]}]},{'model':db[_0xaf44('0x86')],'as':'List','attributes':['id','name']},{'model':db[_0xaf44('0x5b')],'as':_0xaf44('0x87'),'attributes':['id','name',_0xaf44('0x88')]}]})[_0xaf44('0x1f')](function(_0x3b9828){if(_0x3b9828){return _0x3b9828[_0xaf44('0x1d')]({'UserId':_0x2c6b59['user']['id']},{'transaction':_0xfcf175});}});});}})['then'](handleEntityNotFound(_0x717cc3,null))['then'](respondWithResult(_0x717cc3,null))[_0xaf44('0x50')](handleError(_0x717cc3,null));};exports[_0xaf44('0x89')]=function(_0x46fb77,_0x14a7a6,_0x596f26){return _0x46fb77[_0xaf44('0x60')][_0xaf44('0x8a')]({'where':{'type':_0xaf44('0x6f'),'dialActive':!![],'dialMethod':_0xaf44('0x70')},'attributes':['id'],'raw':!![]})[_0xaf44('0x1f')](function(_0x12473c){if(_0x12473c&&_0x12473c[_0xaf44('0x54')]){return db[_0xaf44('0x25')][_0xaf44('0x18')]({'where':{'active':![],'recallme':![],'scheduledAt':{'$lte':moment()[_0xaf44('0x64')](_0xaf44('0x73'))},'VoiceQueueId':{'$in':_[_0xaf44('0x2b')](_0x12473c,'id')},'$or':[{'UserId':null},{'UserId':_0x46fb77[_0xaf44('0x60')]['id']}]}});}return 0x0;})[_0xaf44('0x1f')](function(_0x34c43c){if(!_[_0xaf44('0x69')](_0x34c43c)&&_['isNumber'](_0x34c43c)){return _0x14a7a6[_0xaf44('0x15')](0xc8)[_0xaf44('0x17')]({'contacts':_0x34c43c});}else{logger['error'](_0xaf44('0x8b'),_0xaf44('0x89'),0x194,_0xaf44('0x8c'));_0x14a7a6['sendStatus'](0x194);}})[_0xaf44('0x50')](handleError(_0x14a7a6,null));};
\ No newline at end of file
+var _0x50a6=['CmHopperFinal','getPreview','CmContact','getVoiceQueues','outbound','preview','dialPreviewAutoRecallMe','sequelize','transaction','value','direction','prev','isEmpty','hopperIds','ASC','scheduledAt','dialOrderByScheduledAt','DESC','literal','priority','COALESCE(CmHopper.UserId,\x200)\x20DESC','findOne','LOCK','UPDATE','Contact','CmCompany','Company','CmList','Queue','dialActive','scheduledat','isNumber','CmHopper,\x20%s,\x20%s,\x20%s','getOpenContacts','entity\x20not\x20found','getTimezones','timezones','moment','lodash','api','../../mysqldb','status','offset','limit','count','set','json','update','sendStatus','stack','name','rawAttributes','type','key','map','query','keys','intersection','filters','concat','$and','$or','$gt','$gte','$lt','$lte','$ne','$eq','$not','$between','$notBetween','$in','$notIn','$like','$iLike','$notILike','$contains','$contained','$any','attributes','model','fields','length','nolimit','order','where','pick','filter','merge','options','CmHopper','then','includeAll','include','findAll','catch','show','params','find','create','body','describe','destroy','VoiceQueueId','CampaignId','VoiceQueue','Campaign','omit','dataValues','createdAt','statedesc','deleted','membername','user','UserId','deletedat','format','YYYY-MM-DD\x20HH:mm:ss','calleridnum','phone','campaigntype','queue','ContactId','isNil','calleridname','lastName','finally'];(function(_0x4131c3,_0x3317b1){var _0x31b229=function(_0x5af9c8){while(--_0x5af9c8){_0x4131c3['push'](_0x4131c3['shift']());}};_0x31b229(++_0x3317b1);}(_0x50a6,0xa4));var _0x650a=function(_0x5e70f7,_0x344ec4){_0x5e70f7=_0x5e70f7-0x0;var _0x51aa64=_0x50a6[_0x5e70f7];return _0x51aa64;};'use strict';var moment=require(_0x650a('0x0'));var _=require(_0x650a('0x1'));var qs=require('../../components/parsers/qs');var logger=require('../../config/logger')(_0x650a('0x2'));var shared=require('../../config/environment');var db=require(_0x650a('0x3'))['db'];function respondWithResult(_0x15dd02,_0x2c71ba){_0x2c71ba=_0x2c71ba||0xc8;return function(_0x4a0147){if(_0x4a0147){return _0x15dd02[_0x650a('0x4')](_0x2c71ba)['json'](_0x4a0147);}};}function respondWithFilteredResult(_0x4eabde,_0x2d486d){return function(_0x2d1bb4){if(_0x2d1bb4){var _0x2c22b9=typeof _0x2d486d[_0x650a('0x5')]==='undefined'&&typeof _0x2d486d[_0x650a('0x6')]==='undefined';var _0x3b50e7=_0x2d1bb4[_0x650a('0x7')];var _0x495fca=_0x2c22b9?0x0:_0x2d486d[_0x650a('0x5')];var _0x3bbdca=_0x2c22b9?_0x2d1bb4['count']:_0x2d486d[_0x650a('0x5')]+_0x2d486d['limit'];var _0x142cdb;if(_0x3bbdca>=_0x3b50e7){_0x3bbdca=_0x3b50e7;_0x142cdb=0xc8;}else{_0x142cdb=0xce;}_0x4eabde['status'](_0x142cdb);return _0x4eabde[_0x650a('0x8')]('Content-Range',_0x495fca+'-'+_0x3bbdca+'/'+_0x3b50e7)[_0x650a('0x9')](_0x2d1bb4);}return null;};}function saveUpdates(_0x48077a,_0x33e73d){return function(_0x163e5f){if(_0x163e5f){return _0x163e5f[_0x650a('0xa')](_0x48077a)['then'](function(_0x10fb8f){return _0x10fb8f;});}return null;};}function handleEntityNotFound(_0x3919a7,_0x2f727d){return function(_0x15f2fd){if(!_0x15f2fd){_0x3919a7[_0x650a('0xb')](0x194);}return _0x15f2fd;};}function handleError(_0x24f11f,_0x5b7c74){_0x5b7c74=_0x5b7c74||0x1f4;return function(_0x2460a3){logger['error'](_0x2460a3[_0x650a('0xc')]);if(_0x2460a3[_0x650a('0xd')]){delete _0x2460a3[_0x650a('0xd')];}_0x24f11f['status'](_0x5b7c74)['send'](_0x2460a3);};}exports['index']=function(_0x52e5bb,_0x2ad2d7){var _0x359314={},_0x41d2fa={},_0xd0f717={'count':0x0,'rows':[]};var _0x2a0f0c=_['map'](db['CmHopper'][_0x650a('0xe')],function(_0x1c65f6){return{'name':_0x1c65f6['fieldName'],'type':_0x1c65f6[_0x650a('0xf')][_0x650a('0x10')]};});_0x41d2fa['model']=_[_0x650a('0x11')](_0x2a0f0c,_0x650a('0xd'));_0x41d2fa[_0x650a('0x12')]=_[_0x650a('0x13')](_0x52e5bb[_0x650a('0x12')]);_0x41d2fa['filters']=_[_0x650a('0x14')](_0x41d2fa['model'],_0x41d2fa[_0x650a('0x12')]);_0x41d2fa[_0x650a('0x15')]=_[_0x650a('0x16')](_0x41d2fa[_0x650a('0x15')],[_0x650a('0x17'),_0x650a('0x18'),_0x650a('0x19'),_0x650a('0x1a'),_0x650a('0x1b'),_0x650a('0x1c'),_0x650a('0x1d'),_0x650a('0x1e'),_0x650a('0x1f'),_0x650a('0x20'),_0x650a('0x21'),_0x650a('0x22'),_0x650a('0x23'),_0x650a('0x24'),'$notLike',_0x650a('0x25'),_0x650a('0x26'),_0x650a('0x24'),'$overlap',_0x650a('0x27'),_0x650a('0x28'),_0x650a('0x29')]);_0x359314[_0x650a('0x2a')]=_[_0x650a('0x14')](_0x41d2fa[_0x650a('0x2b')],qs['fields'](_0x52e5bb[_0x650a('0x12')][_0x650a('0x2c')]));_0x359314[_0x650a('0x2a')]=_0x359314[_0x650a('0x2a')][_0x650a('0x2d')]?_0x359314[_0x650a('0x2a')]:_0x41d2fa[_0x650a('0x2b')];if(!_0x52e5bb[_0x650a('0x12')]['hasOwnProperty'](_0x650a('0x2e'))){_0x359314[_0x650a('0x6')]=qs[_0x650a('0x6')](_0x52e5bb['query'][_0x650a('0x6')]);_0x359314[_0x650a('0x5')]=qs['offset'](_0x52e5bb[_0x650a('0x12')][_0x650a('0x5')]);}_0x359314[_0x650a('0x2f')]=qs['sort'](_0x52e5bb['query']['sort']);_0x359314[_0x650a('0x30')]=qs[_0x650a('0x15')](_[_0x650a('0x31')](_0x52e5bb[_0x650a('0x12')],_0x41d2fa['filters']),_0x2a0f0c);if(_0x52e5bb[_0x650a('0x12')][_0x650a('0x32')]){_0x359314['where']=_[_0x650a('0x33')](_0x359314[_0x650a('0x30')],{'$or':_[_0x650a('0x11')](_0x2a0f0c,function(_0xd2256b){if(_0xd2256b[_0x650a('0xf')]!=='VIRTUAL'){var _0x14260e={};_0x14260e[_0xd2256b['name']]={'$like':'%'+_0x52e5bb[_0x650a('0x12')][_0x650a('0x32')]+'%'};return _0x14260e;}})});}_0x359314=_['merge']({},_0x359314,_0x52e5bb[_0x650a('0x34')]);var _0xa0e8ec={'where':_0x359314['where']};return db[_0x650a('0x35')][_0x650a('0x7')](_0xa0e8ec)[_0x650a('0x36')](function(_0x53179e){_0xd0f717[_0x650a('0x7')]=_0x53179e;if(_0x52e5bb[_0x650a('0x12')][_0x650a('0x37')]){_0x359314[_0x650a('0x38')]=[{'all':!![]}];}return db['CmHopper'][_0x650a('0x39')](_0x359314);})[_0x650a('0x36')](function(_0x2ace75){_0xd0f717['rows']=_0x2ace75;return _0xd0f717;})['then'](respondWithFilteredResult(_0x2ad2d7,_0x359314))[_0x650a('0x3a')](handleError(_0x2ad2d7,null));};exports[_0x650a('0x3b')]=function(_0x5b33c9,_0x1acbe5){var _0x48bdd4={'raw':!![],'where':{'id':_0x5b33c9[_0x650a('0x3c')]['id']}},_0x3ebe8b={};_0x3ebe8b[_0x650a('0x2b')]=_[_0x650a('0x13')](db[_0x650a('0x35')]['rawAttributes']);_0x3ebe8b[_0x650a('0x12')]=_['keys'](_0x5b33c9[_0x650a('0x12')]);_0x3ebe8b[_0x650a('0x15')]=_[_0x650a('0x14')](_0x3ebe8b[_0x650a('0x2b')],_0x3ebe8b[_0x650a('0x12')]);_0x48bdd4[_0x650a('0x2a')]=_[_0x650a('0x14')](_0x3ebe8b['model'],qs['fields'](_0x5b33c9[_0x650a('0x12')]['fields']));_0x48bdd4['attributes']=_0x48bdd4[_0x650a('0x2a')]['length']?_0x48bdd4[_0x650a('0x2a')]:_0x3ebe8b['model'];if(_0x5b33c9[_0x650a('0x12')][_0x650a('0x37')]){_0x48bdd4[_0x650a('0x38')]=[{'all':!![]}];}_0x48bdd4=_[_0x650a('0x33')]({},_0x48bdd4,_0x5b33c9[_0x650a('0x34')]);return db[_0x650a('0x35')][_0x650a('0x3d')](_0x48bdd4)[_0x650a('0x36')](handleEntityNotFound(_0x1acbe5,null))[_0x650a('0x36')](respondWithResult(_0x1acbe5,null))[_0x650a('0x3a')](handleError(_0x1acbe5,null));};exports[_0x650a('0x3e')]=function(_0x381632,_0x4ac78e){return db[_0x650a('0x35')][_0x650a('0x3e')](_0x381632[_0x650a('0x3f')],{})[_0x650a('0x36')](respondWithResult(_0x4ac78e,0xc9))[_0x650a('0x3a')](handleError(_0x4ac78e,null));};exports[_0x650a('0xa')]=function(_0x5b23b5,_0x2c692b){if(_0x5b23b5[_0x650a('0x3f')]['id']){delete _0x5b23b5[_0x650a('0x3f')]['id'];}return db[_0x650a('0x35')][_0x650a('0x3d')]({'where':{'id':_0x5b23b5[_0x650a('0x3c')]['id']}})['then'](handleEntityNotFound(_0x2c692b,null))['then'](saveUpdates(_0x5b23b5[_0x650a('0x3f')],null))[_0x650a('0x36')](respondWithResult(_0x2c692b,null))[_0x650a('0x3a')](handleError(_0x2c692b,null));};exports['describe']=function(_0x16fc65,_0x5b360a){return db[_0x650a('0x35')][_0x650a('0x40')]()['then'](respondWithResult(_0x5b360a,null))[_0x650a('0x3a')](handleError(_0x5b360a,null));};exports[_0x650a('0x41')]=function(_0x39e8e6,_0x47ec0d){var _0x40f9eb;var _0x3e7cfc=_0x39e8e6[_0x650a('0x3c')]['id'];return db['CmHopper'][_0x650a('0x3d')]({'where':{'id':_0x39e8e6[_0x650a('0x3c')]['id']}})[_0x650a('0x36')](handleEntityNotFound(_0x47ec0d,null))[_0x650a('0x36')](function(_0x134cb5){if(_0x134cb5){return _0x134cb5['destroy']()['then'](function(_0x215f2e){return _0x215f2e;});}})[_0x650a('0x36')](function(_0x5b2907){_0x40f9eb=_0x5b2907;if(_0x5b2907){if(_0x5b2907[_0x650a('0x42')]||_0x5b2907[_0x650a('0x43')]){return db[_0x5b2907[_0x650a('0x42')]?_0x650a('0x44'):_0x650a('0x45')][_0x650a('0x3d')]({'where':{'id':_0x5b2907['VoiceQueueId']?_0x5b2907[_0x650a('0x42')]:_0x5b2907[_0x650a('0x43')]},'attributes':['id',_0x650a('0xd')],'raw':!![]});}}})[_0x650a('0x36')](function(_0xeb5d49){var _0x5206bf={};if(_0xeb5d49){_[_0x650a('0x33')](_0x5206bf,_[_0x650a('0x46')](_0x40f9eb[_0x650a('0x47')],[_0x650a('0x48'),'updatedAt','id']));_0x5206bf['state']=0x15;_0x5206bf[_0x650a('0x49')]=_0x650a('0x4a');_0x5206bf['campaign']=_0xeb5d49[_0x650a('0xd')];_0x5206bf[_0x650a('0x4b')]=_0x39e8e6[_0x650a('0x4c')][_0x650a('0xd')];_0x5206bf[_0x650a('0x4d')]=_0x39e8e6[_0x650a('0x4c')]['id'];_0x5206bf[_0x650a('0x4a')]=!![];_0x5206bf[_0x650a('0x4e')]=moment()[_0x650a('0x4f')](_0x650a('0x50'));_0x5206bf[_0x650a('0x51')]=_0x40f9eb[_0x650a('0x52')];_0x5206bf[_0x650a('0x53')]=_0x40f9eb[_0x650a('0x42')]?_0x650a('0x54'):'ivr';return db['CmContact'][_0x650a('0x3d')]({'where':{'id':_0x5206bf[_0x650a('0x55')]},'attributes':['firstName','lastName']})[_0x650a('0x36')](function(_0x56031a){if(!_[_0x650a('0x56')](_0x47ec0d)&&!_['isNil'](_0x56031a['firstName'])){_0x5206bf[_0x650a('0x57')]=_0x56031a['firstName'];if(!_[_0x650a('0x56')](_0x56031a[_0x650a('0x58')])){_0x5206bf['calleridname']+='\x20'+_0x56031a[_0x650a('0x58')];}}})[_0x650a('0x59')](function(){return db[_0x650a('0x5a')][_0x650a('0x3e')](_0x5206bf);});}})[_0x650a('0x36')](function(_0x2e7347){return db['CmHopperAdditionalPhone'][_0x650a('0x41')]({'where':{'CmHopperId':_0x3e7cfc}});})[_0x650a('0x36')](function(){return _0x47ec0d[_0x650a('0x4')](0xcc)['end']();})[_0x650a('0x3a')](handleError(_0x47ec0d,null));};exports[_0x650a('0x5b')]=function(_0x431ef9,_0x5920a6){var _0x581ead=[];return db[_0x650a('0x5c')][_0x650a('0x40')]()['then'](function(_0x2fa55b){_0x581ead=_[_0x650a('0x13')](_0x2fa55b);return _0x431ef9[_0x650a('0x4c')][_0x650a('0x5d')]({'where':{'type':_0x650a('0x5e'),'dialActive':!![],'dialMethod':_0x650a('0x5f')},'attributes':['id','dialOrderByScheduledAt',_0x650a('0x60')],'raw':!![]});})[_0x650a('0x36')](function(_0x19f11b){if(_0x19f11b&&_0x19f11b['length']){return db[_0x650a('0x61')][_0x650a('0x62')](function(_0x576834){var _0x2ca5c0={'active':![],'recallme':![],'scheduledAt':{'$lte':moment()['format'](_0x650a('0x50'))},'VoiceQueueId':{'$in':_['map'](_0x19f11b,'id')},'$or':[{'UserId':null},{'UserId':_0x431ef9[_0x650a('0x4c')]['id']}]};var _0x1564c0={'active':![],'recallme':!![],'VoiceQueueId':{'$in':_(_0x19f11b)['filter']([_0x650a('0x60'),0x0])[_0x650a('0x11')]('id')[_0x650a('0x63')]()},'$or':[{'UserId':null},{'UserId':_0x431ef9[_0x650a('0x4c')]['id']}]};var _0x3205e4={'$or':[_0x2ca5c0,_0x1564c0]};var _0x3bd508=[];if(_0x431ef9[_0x650a('0x3f')][_0x650a('0x64')]&&_0x431ef9[_0x650a('0x3f')][_0x650a('0x64')]===_0x650a('0x65')){if(!_[_0x650a('0x66')](_0x431ef9[_0x650a('0x3f')]['hopperIds'])){_0x3205e4['id']={'$in':_0x431ef9['body'][_0x650a('0x67')]};}_0x3bd508=[['priority',_0x650a('0x68')],[_0x650a('0x69'),_0x19f11b[0x0][_0x650a('0x6a')]===_0x650a('0x68')?_0x650a('0x6b'):_0x650a('0x68')],db['sequelize'][_0x650a('0x6c')]('COALESCE(CmHopper.UserId,\x200)\x20ASC'),['id',_0x650a('0x6b')]];}else{if(!_[_0x650a('0x66')](_0x431ef9[_0x650a('0x3f')][_0x650a('0x67')])){_0x3205e4['id']={'$notIn':_0x431ef9[_0x650a('0x3f')]['hopperIds']};}_0x3bd508=[[_0x650a('0x6d'),_0x650a('0x6b')],[_0x650a('0x69'),_0x19f11b[0x0][_0x650a('0x6a')]],db[_0x650a('0x61')][_0x650a('0x6c')](_0x650a('0x6e')),['id',_0x650a('0x68')]];}return db[_0x650a('0x35')][_0x650a('0x6f')]({'attributes':['id','scheduledat','phone','recallme'],'where':_0x3205e4,'order':_0x3bd508,'transaction':_0x576834,'lock':_0x576834[_0x650a('0x70')][_0x650a('0x71')],'include':[{'model':db['CmContact'],'as':_0x650a('0x72'),'attributes':_0x581ead,'include':[{'model':db[_0x650a('0x73')],'as':_0x650a('0x74'),'attributes':['id','name']}]},{'model':db[_0x650a('0x75')],'as':'List','attributes':['id',_0x650a('0xd')]},{'model':db[_0x650a('0x44')],'as':_0x650a('0x76'),'attributes':['id',_0x650a('0xd'),_0x650a('0x77')]}]})['then'](function(_0x5e0dd7){if(_0x5e0dd7){return _0x5e0dd7[_0x650a('0xa')]({'UserId':_0x431ef9[_0x650a('0x4c')]['id']},{'transaction':_0x576834});}});});}})[_0x650a('0x36')](handleEntityNotFound(_0x5920a6,null))['then'](respondWithResult(_0x5920a6,null))[_0x650a('0x3a')](handleError(_0x5920a6,null));};exports['getPreviewRecall']=function(_0x4c29ba,_0x3767e1,_0x409f8b){var _0x383fb3=[];var _0x39b2d2=_0x4c29ba[_0x650a('0x3c')]['id'];var _0x50dfbb=_0x4c29ba[_0x650a('0x4c')]['id'];return db[_0x650a('0x5c')][_0x650a('0x40')]()['then'](function(_0x537688){_0x383fb3=_[_0x650a('0x13')](_0x537688);return db['sequelize']['transaction'](function(_0x48b3f4){const _0x14211e={'id':_0x39b2d2};return db['CmHopper']['findOne']({'attributes':['id',_0x650a('0x78'),'recallme'],'where':_0x14211e,'transaction':_0x48b3f4,'lock':_0x48b3f4[_0x650a('0x70')]['UPDATE'],'include':[{'model':db[_0x650a('0x5c')],'as':_0x650a('0x72'),'attributes':_0x383fb3,'include':[{'model':db[_0x650a('0x73')],'as':_0x650a('0x74'),'attributes':['id','name']}]},{'model':db[_0x650a('0x75')],'as':'List','attributes':['id','name']},{'model':db[_0x650a('0x44')],'as':_0x650a('0x76'),'attributes':['id',_0x650a('0xd'),_0x650a('0x77')]}]})[_0x650a('0x36')](function(_0x7701cc){if(_0x7701cc){return _0x7701cc['update']({'UserId':_0x50dfbb},{'transaction':_0x48b3f4});}});});})[_0x650a('0x36')](handleEntityNotFound(_0x3767e1,null))[_0x650a('0x36')](respondWithResult(_0x3767e1,null))[_0x650a('0x3a')](handleError(_0x3767e1,null));};exports['getOpenContacts']=function(_0x13e6fe,_0x1fec64){return _0x13e6fe[_0x650a('0x4c')][_0x650a('0x5d')]({'where':{'type':_0x650a('0x5e'),'dialActive':!![],'dialMethod':'preview'},'attributes':['id'],'raw':!![]})[_0x650a('0x36')](function(_0x2e62f3){if(_0x2e62f3&&_0x2e62f3['length']){return db[_0x650a('0x35')]['count']({'where':{'active':![],'recallme':![],'scheduledAt':{'$lte':moment()['format'](_0x650a('0x50'))},'VoiceQueueId':{'$in':_[_0x650a('0x11')](_0x2e62f3,'id')},'$or':[{'UserId':null},{'UserId':_0x13e6fe['user']['id']}]}});}return 0x0;})[_0x650a('0x36')](function(_0x446c6f){if(!_[_0x650a('0x56')](_0x446c6f)&&_[_0x650a('0x79')](_0x446c6f)){return _0x1fec64[_0x650a('0x4')](0xc8)[_0x650a('0x9')]({'contacts':_0x446c6f});}else{logger['error'](_0x650a('0x7a'),_0x650a('0x7b'),0x194,_0x650a('0x7c'));_0x1fec64[_0x650a('0xb')](0x194);}})[_0x650a('0x3a')](handleError(_0x1fec64,null));};exports[_0x650a('0x7d')]=function(_0x5631bf,_0x16e596){var _0xcf6cb3=shared[_0x650a('0x7e')];var _0x2fb487=[];_[_0x650a('0x11')](_0xcf6cb3,function(_0x273943){_0x2fb487['push']({'id':_0x273943[_0x650a('0xd')],'name':_0x273943[_0x650a('0xd')],'utcOffset':_0x273943['utcOffset']});});return _0x16e596[_0x650a('0x4')](0xc8)[_0x650a('0x9')]({'tz':_0x2fb487});};exports['getTimezone']=function(_0x47e6a6,_0x5dd509){var _0x137bdd=shared[_0x650a('0x7e')];var _0x20780e={};if(!_['isNil'](_0x137bdd[_0x47e6a6[_0x650a('0x3f')]['id']]))_0x20780e=_0x137bdd[_0x47e6a6[_0x650a('0x3f')]['id']];return _0x5dd509[_0x650a('0x4')](0xc8)[_0x650a('0x9')](_0x20780e);};
\ No newline at end of file